We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10395
    • 96 Posts
    I tried searching for this, but couldn’t find anything of assistance. I know Modx uses a library called MooTools...however, I am trying to include jQuery into Modx and it’s not working. It just ignores any jQuery I have placed inside a document.  Does it need to be placed anywhere special in order to be parsed, like a chunk?

    Just to note, I have it working offline, outside of Modx.  I have included ’jquery.js’ into my templates header.

    Thanks.

    EDIT: Looks that it works when I’m not logged into the Manager, but doesn’t work when I am. Conflict perhaps?
      • 16867
      • 10 Posts
      I ran into the same problem and got around it by using jQuery’s noConflict() function.

      See here which goes into a lot more detail:
      http://docs.jquery.com/Using_jQuery_with_Other_Libraries

      The gist of it is you can either use this before your own jQuery code (NOT the library):
      jQuery.noConflict();
      and then switch every single "$" in your jQuery code (again, YOUR code, not the jquery.js library itself) to "jQuery," as in
      jQuery(document).ready(function(){
             jQuery("div").hide(); //using 'jQuery' instead of '$'
           });
      


      Or if you’re attached to ’$’ shortcut you can do this:
      jQuery.noConflict();
      
      jQuery(document).ready(function($){ //note the '$' in function($)
         $("div").hide(); //you can keep using '$' here
      });
      


      You might also have to adjust any plugins you’re using like this:
      (function($) { /* lots of plugin code that likely uses $ */ })(jQuery)
      
        • 10395
        • 96 Posts
        Ah, perfect! Thanks smiley.