Facebook Connect, jQuery UI, and jQuery.noConflict()

前端 未结 1 998
别跟我提以往
别跟我提以往 2020-12-14 05:44

I\'m trying to build a page on my personal website that both used jQuery and implements Facebook Connect.

Unfortunately, the Facebook

相关标签:
1条回答
  • 2020-12-14 05:56

    The post you've referenced is quite old and out of date. The 1.0 release of jQuery UI had this issue in a couple of files and was fixed as soon as it was reported.

    All of jQuery UI is wrapped in a closure that passes in jQuery as $ and therefore can use $ internally while $ is used for something else externally.

    From http://docs.jquery.com/Using_jQuery_with_Other_Libraries#Referencing_Magic_-_Shortcuts_for_jQuery

    Use the following technique, which allows you to use $ inside of a block of code without permanently overwriting $:

    (function($) {
      /* some code that uses $ */
    })(jQuery)
    

    Note: If you use this technique, you can still use Prototype via window.$ e.g., window.$('some_element_id'). Any function outside of your closure that references $ will invoke Prototype, even if called from inside your closure.

    This is why you'll see $ inside the jQuery UI files, but rest assured, any recent version of jQuery UI (1.5+) is completely supported with jQuery.noConflict()

    0 讨论(0)
提交回复
热议问题