1,105,375 Community Members

jQuery noCoflict(true) question

Member Avatar
PaliGap
Newbie Poster
11 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I have a project where my code will have to coexist with code in web pages designed elsewhere. My code will use jQuery, and so there may be an issue if the parent page already runs jQuery (and maybe jQuery plugins).

I would have thought the correct thing to do would be to add my jQuery version at the closing <body> tag (so it loads last) and then do:

var myJQ=jQuery.noConflict(true);

That way I hand back '$' and 'jQuery' to the page's own jQuery code and plugins so that they use the version of jQuery for which they were designed. But the jQuery docs warn that using 'true' may prevent other plugins working. I would like to understand that - but I'm afraid I don't get it! Surely it's the other way round? If I simply do "noConflict()", then pre-existing code using the jQuery variable will be using a different version than planned for, and that might cause problems? Whereas "noConflict(true)" would protect against that?

Member Avatar
riahc3
 
1,404 posts since May 2008
Reputation Points: 45 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 18 [?]
Team Colleague
 
0
 

I have a project where my code will have to coexist with code in web pages designed elsewhere. My code will use jQuery, and so there may be an issue if the parent page already runs jQuery (and maybe jQuery plugins). I would have thought the correct thing to do would be to add my jQuery version at the closing <body> tag (so it loads last) and then do: var myJQ=jQuery.noConflict(true); That way I hand back '$' and 'jQuery' to the page's own jQuery code and plugins so that they use the version of jQuery for which they were designed. But the jQuery docs warn that using 'true' may prevent other plugins working. I would like to understand that - but I'm afraid I don't get it! Surely it's the other way round? If I simply do "noConflict()", then pre-existing code using the jQuery variable will be using a different version than planned for, and that might cause problems? Whereas "noConflict(true)" would protect against that?

I have a project where my code will have to coexist with code in web pages designed elsewhere. My code will use jQuery, and so there may be an issue if the parent page already runs jQuery (and maybe jQuery plugins). I would have thought the correct thing to do would be to add my jQuery version at the closing <body> tag (so it loads last) and then do: var myJQ=jQuery.noConflict(true); That way I hand back '$' and 'jQuery' to the page's own jQuery code and plugins so that they use the version of jQuery for which they were designed. But the jQuery docs warn that using 'true' may prevent other plugins working. I would like to understand that - but I'm afraid I don't get it! Surely it's the other way round? If I simply do "noConflict()", then pre-existing code using the jQuery variable will be using a different version than planned for, and that might cause problems? Whereas "noConflict(true)" would protect against that?

I have a project where my code will have to coexist with code in web pages designed elsewhere. My code will use jQuery, and so there may be an issue if the parent page already runs jQuery (and maybe jQuery plugins). I would have thought the correct thing to do would be to add my jQuery version at the closing <body> tag (so it loads last) and then do: var myJQ=jQuery.noConflict(true); That way I hand back '$' and 'jQuery' to the page's own jQuery code and plugins so that they use the version of jQuery for which they were designed. But the jQuery docs warn that using 'true' may prevent other plugins working. I would like to understand that - but I'm afraid I don't get it! Surely it's the other way round? If I simply do "noConflict()", then pre-existing code using the jQuery variable will be using a different version than planned for, and that might cause problems? Whereas "noConflict(true)" would protect against that?

I have a project where my code will have to coexist with code in web pages designed elsewhere. My code will use jQuery, and so there may be an issue if the parent page already runs jQuery (and maybe jQuery plugins). I would have thought the correct thing to do would be to add my jQuery version at the closing <body> tag (so it loads last) and then do: var myJQ=jQuery.noConflict(true); That way I hand back '$' and 'jQuery' to the page's own jQuery code and plugins so that they use the version of jQuery for which they were designed. But the jQuery docs warn that using 'true' may prevent other plugins working. I would like to understand that - but I'm afraid I don't get it! Surely it's the other way round? If I simply do "noConflict()", then pre-existing code using the jQuery variable will be using a different version than planned for, and that might cause problems? Whereas "noConflict(true)" would protect against that?

I didnt even know "noConflict" used parameters.

I usually declare:

var $j = jQuery.noConflict(); 

Then use "$j".

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: