<![CDATA[ Add some JS to a manager page - My Forums]]> https://forums.modx.com/thread/?thread=85913 <![CDATA[Add some JS to a manager page]]> https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473607
I am just working my way through learning ModX and have created a custom input page in the manager using Form Customization. I would like to add a bit of javascript to hide/show some of the form fields depending what is set in some radio buttons.

regClientScript seems to be what is needed but I can't figure out where to add it.

Any suggestions gratefully received.

Thanks

Pete]]>
petejl Jul 31, 2013, 01:05 PM https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473607
<![CDATA[Re: Add some JS to a manager page]]> https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-526976 Quote from: pepebe at Mar 03, 2014, 12:30 AM
Sadly he doesn't give a reason why adding code to the body element is not possible, but adding code to the head is ok.
Sorry for bumping old thread - but I guess I have an answer (sort of).
For those who come here googling, here is the reason in case if you use Minifyx (https://github.com/bezumkin/MinifyX): https://github.com/bezumkin/MinifyX/issues/18 . So the solution is either to disable minifyx_process_registered option (set it to false) or update Minifyx to the latest version (be aware of https://github.com/bezumkin/MinifyX/issues/19 though (in Russian)).
Then all of regClientHTMLBlock should begin working.]]>
patchranger Jun 15, 2015, 01:13 AM https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-526976
<![CDATA[Re: Add some JS to a manager page]]> https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-491613
http://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/snippets/adding-css-and-js-to-your-pages-through-snippets

Example:
<?php
switch ($modx->event->name) {
    case 'OnDocFormPrerender': // Activated in plugin settings
        /* these works */
        $modx->regClientStartupHTMLBlock('<script>console.log("html block added");</script>');
        $modx->regClientStartupScript(MODX_ASSETS_URL.'components/help/help_header.js');
        $modx->regClientCSS(MODX_ASSETS_URL.'components/help/help.css');
        /* these don't*/
        $modx->regClientScript(MODX_ASSETS_URL.'components/help/help_footer.js');
        $modx->regClientHTMLBlock('<script>console.log("Some script block added");</script>');
        break;
}
return;


As you can see here only the first three register functions have an effect. The two below don't have any effect. Is it possible, that I need to use some other event to trigger them?

Regards, pepebe

P.S. I've found a three year old bug report on jira (http://tracker.modx.com/issues/353). In this report splittingred states that regClientStartupHTMLBlock should be used instead of regClientHTMLBlock. Sadly he doesn't give a reason why adding code to the body element is not possible, but adding code to the head is ok.
]]>
pepebe Mar 02, 2014, 06:30 PM https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-491613
<![CDATA[Re: Add some JS to a manager page]]> https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473942
I eventually, with some more research in Sencha Docs and stackoverflow, gleaned enough knowledge of EXT to get a working demo.

Thanks for your patience and help.

Pete]]>
petejl Aug 03, 2013, 04:56 PM https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473942
<![CDATA[Re: Add some JS to a manager page]]> https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473929 sottwell Aug 03, 2013, 10:33 AM https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473929 <![CDATA[Re: Add some JS to a manager page]]> https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473928 Quote from: sottwell at Aug 03, 2013, 09:50 AM
It may well be that the page foot is not inserted in time for the regClientScript() function to find the closing tag.

That sounds entirely possible. I am running Chrome on a Dell Dimension with XP pro, to say that Modx Manager runs slowly would be being very polite! Obviously a workstation upgrade is called for if we start using Modx seriously.]]>
petejl Aug 03, 2013, 10:27 AM https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473928
<![CDATA[Re: Add some JS to a manager page]]> https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473922 sottwell Aug 03, 2013, 09:50 AM https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473922 <![CDATA[Re: Add some JS to a manager page]]> https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473920 BobRay Aug 03, 2013, 08:30 AM https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page?page=2#dis-post-473920 <![CDATA[Re: Add some JS to a manager page]]> https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page#dis-post-473918
Bob - I will try it again but regClientScript() definitely did not load any js script. I was checking the bottom of the html immediately above the closing body tag. I just changed the plugin to run off regClientStartupScript() and it worked immediately.

Regards

Pete]]>
petejl Aug 03, 2013, 08:25 AM https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page#dis-post-473918
<![CDATA[Re: Add some JS to a manager page]]> https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page#dis-post-473896
]]>
BobRay Aug 02, 2013, 09:27 PM https://forums.modx.com/thread/85913/add-some-js-to-a-manager-page#dis-post-473896