- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2020
08:14 PM
02-13-2020
08:14 PM
How to run javascript from dynamic cms block
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?
Labels:
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2020
09:12 PM
02-13-2020
09:12 PM
Re: How to run javascript from dynamic cms block
@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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2020
09:54 PM
02-13-2020
09:54 PM
Re: How to run javascript from dynamic cms block
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2022
12:48 PM
04-06-2022
12:48 PM
Re: How to run javascript from dynamic cms block
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>