On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • 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().
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
      • It may well be that the page foot is not inserted in time for the regClientScript() function to find the closing </body> tag.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
        • 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.
          • 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.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
            • 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 6 years, 1 month ago.]
                  Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
                • 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.