Overcome problems when old Project contain a JavaScript library which contain global function called $ that want to include jQuery into it.

OR

What is jQuery.noConflict ?

Let say we have an old maintenance project with us and now we want to include jQuery into it.

What is the problem?
Project contain a JavaScript library which contain global function called $. This situation will create a conflict because both jQuery and one of the previous library contain $ function and obviously one of them is going to overridden.
What is the solution?
Now in order to overcome such situation jQuery has introduced jQuery.noConflict
var  # = jQuery.noConflict();
// Use jQuery via jQuery(…)
#(document).ready( function  ()
{
    #( “div” ).fadeIn();
});

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s