Using jQuery noConflict() with script.aculo.us

前端 未结 4 1689
萌比男神i
萌比男神i 2021-01-16 08:12

I have a site using a \"widget\" (from http://healcode.com) that includes the script.aculo.us JavaScript library. The problem is that the site I\'m building is on WordPress,

相关标签:
4条回答
  • 2021-01-16 08:17

    This worked for me so that I can have jQuery and script.aculo.us/Prototype working well together. Credit goes to codeimpossible for this lifesaver!

    Instead of:

    jQuery(document).ready(function () {
    
        // Code to run on DOM ready
    
    }); // End document.ready
    

    Try this:

    ( function($) {
    
        // Code to run on DOM ready
    
    } )( jQuery ); // End document.ready
    
    0 讨论(0)
  • 2021-01-16 08:27

    Try this:

    <script src="url to jquery"></script>
    <script type="javascript">jQuery.noConflict();</script>
    <script src="url to scriptaculous"></script>
    
    0 讨论(0)
  • 2021-01-16 08:28

    I found the solution VERY surprising!

    First of all, using the $j = jQuery.noConflict(); mode did not work.

    Second, calling jQuery.noConflict(); at the head did not work.

    The method that did work was this one: http://codeimpossible.com/2010/01/13/solving-document-ready-is-not-a-function-and-other-problems/

    Oddly, the Coda Slider 2.0 plugin does not automatically do noConflict so it turned out that IN ADDITION to the problems listed above, I needed to wrap that plugin in .noConflict(); as well. Shout out the the author of the blog post, not sure why other noConflict(); calling methods didn't work, but I'm glad I found the post.

    0 讨论(0)
  • 2021-01-16 08:30

    Assigning jQuery right back to $ doesn't do anything.

    Either assign jQuery to a different variable:

    var j$ = jQuery.noConflict();
    

    Or don't assign it to anything:

    jQuery.noConflict();
    
    0 讨论(0)
提交回复
热议问题