Everett - thanks I had been looking at the tutorials. I have also ordered the EXT js book which will point me in the right direction.
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
Interesting. Anyway, there's nothing wrong with using regClientStarupScript().
-
☆ A M B ☆
- 24,524 Posts
It may well be that the page foot is not inserted in time for the regClientScript() function to find the closing </body> tag.
-
☆ A M B ☆
- 24,524 Posts
That has nothing to do with the speed of your machine, but with the order in which the processing of the page is done. If the regClientScript() function is processed and its output inserted to the page's content before the footer part is added, then it won't find the closing body tag to place the javascript. With Smarty involved in the mix, it's very difficult to follow the exact steps taken in generating a Manager page.
Hi Guys
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
I'm hitting about the same wall as the author of this thread and I'd like some clarification which register functions are available in the manager at what event:
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.
[ed. note: pepebe last edited this post 10 years, 10 months ago.]