If I add some javascript to a dynamic cms block and add the block to a cms page, the block content along with the js will be loaded via ajax and inserted to dom, but the js inside the block won't run.
Is it expected behavior and how do we fix/improve it?
@KuafuSoft when you add the js in cms block it will run when it is added in the dom.
Can you please share the error which you are getting?
Thanks
No error. I'm not using the regular cms block, but the dynamic cms block from M2 EE version.
The content is being injected via ajax
I was able to resolve that issue for myself using afterRender function in 'HTML code' Pagebuilder element
<div data-bind="afterRender: function(elem) { // Your js logic here }"></div>