We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10378
    • 375 Posts
    Hi,

    I just try to include jQuery in a CMP. What is the correct way to do this?

    Currently I tried this in MyHomeManagerController of my CMP:

        public function loadCustomCssJs() {
            // load libraries
            $this->addJavascript($this->goodnews->config['jsUrl'].'mgr/jquery/jquery-1.9.1.min.js');
            $this->addJavascript($this->goodnews->config['jsUrl'].'mgr/jquery/plugins.js');
            ....
    



    But this doesn't work. It seems MODx tries to minify the added JS code.

    Thanks for your help,
    Martin [ed. note: gadgetto last edited this post 13 years, 7 months ago.]
      Freelancer @bitego http://www.bitego.com
      ---
      GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
      More infos here: http://www.bitego.com/extras/goodnews/
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      However, you don't have to use ExtJS in your Custom Manager Pages - you can use plain HTML, or another JS framework, if you like. If you do decide to use another JS framework, MODx recommends that you not set "Load Headers" to true on the modAction, since this will load the ExtJS scripts. You'll need to create your own header file and output that with your normal output.
        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
        • 10378
        • 375 Posts
        Quote from: sottwell at Feb 18, 2013, 07:20 AM
        However, you don't have to use ExtJS in your Custom Manager Pages - you can use plain HTML, or another JS framework, if you like. If you do decide to use another JS framework, MODx recommends that you not set "Load Headers" to true on the modAction, since this will load the ExtJS scripts. You'll need to create your own header file and output that with your normal output.

        Thanks for the hint Susan!
          Freelancer @bitego http://www.bitego.com
          ---
          GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
          More infos here: http://www.bitego.com/extras/goodnews/
          • 3749
          • 24,544 Posts
          You might try $modx->regClientStartupScript(). That will work in the front-end, I don't know if it's correct for a CMP.
            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