Facebook Connect, jQuery UI and jQuery.noConflict ()

I am trying to create a page on my personal website that uses jQuery and implements Facebook Connect .

Unfortunately, the Facebook client API uses $ token , which means I have to call jQuery.noConflict()

Double, unfortunately, I found that for some crazy reason and as Rick Strall points out, jQuery UI does not respect noConlict (). In fact. In fact, if you look at the source code, there is $ .

I really want to use the jQuery UI - in particular, the dialog() and draggable component would also be very nice - but I don’t even want to manually edit - and check and save - my own copy of any part of the jQuery user interface.

This is the last of a series of yaks that I had to shave , which are on my mind. Any suggestions? Help!

+6
jquery api jquery-ui facebook
source share
1 answer

The message you are linking to is pretty outdated and outdated. The jQuery UI release 1.0 had this problem in several files and was fixed as soon as it was submitted.

The whole jQuery user interface is enclosed in closure , which runs in jQuery as $ and therefore can use $ internal, and $ is used for something else externally.

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

Use the following method, which allows you to use $ inside a code block without constantly rewriting $:

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

Note. If you use this method, you can still use Prototype with window.$ , For example, window.$('some_element_id') . Any function outside your closure that references $ is called by Prototype, even if called from your closure.

That's why you will see $ inside jQuery custom files, but rest assured, any latest version of jQuery UI (1.5+) fully supported by jQuery.noConflict()

+18
source share

All Articles