Timeline for Magento 2 : add custom JavaScript to CMS page create/edit in admin
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 31, 2018 at 7:01 | comment | added | Pallavi Sinha | Hi Nico, how to open the fieldset here with js? I am trying to add some js code for the cms form but its not there yet. any suggestions? | |
Oct 2, 2017 at 5:08 | comment | added | Nico V | I did, but the fields only get rendered after opening its corresponding fieldset, so just a timeout didn't cut it. I had to set a timeout for rendering the fieldsets and after they were set, set a listener for opening a specific fieldset to allow getting the data from the desired fields. | |
Sep 30, 2017 at 14:17 | comment | added | Sohel Rana | Try to set timeout for 5sec, then you can able to catch field. | |
Sep 30, 2017 at 14:06 | comment | added | Nico V | I think I found out what happens: apparently Magento 2 load all "fieldsets" on the admin pages, but doesn't load the underlying fields until clicked on the fieldset, that's why my js couldn't find the values, because they were not yet set. Now I'm checking if they are already set and if not, listen on the openining of the fieldset before trying again. What I want to do is be able to link CMS pages to other pages (which I got working), but exclude the current page from the list of selectable pages to link to. | |
Sep 29, 2017 at 11:36 | comment | added | Sohel Rana | What you actually want? This code added custom block as well as template with JS. | |
Sep 29, 2017 at 11:25 | comment | added | Nico V | So after some more messing around, I found it is not Ajax, the fields just don't get renered until you click the parent fieldset (open the fieldset). That makes things a bit difficult. I'm still trying to figure out how to go about this. | |
Sep 29, 2017 at 8:45 | comment | added | Nico V | There's still a problem, the page seems to be rendered via Ajax I think, so whenever I try to log a value from one of the inputs from 'cms_page_form.xml' I get an undefined. How do I make it load after all form fields have rendered? | |
Sep 25, 2017 at 13:44 | history | answered | Sohel Rana | CC BY-SA 3.0 |