We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,548 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

jQuery noCoflict(true) question

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?

2
Contributors
1
Reply
34 Minutes
Discussion Span
5 Months Ago
Last Updated
2
Views
PaliGap
Newbie Poster
11 posts since May 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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".

riahc3
 
Team Colleague
1,311 posts since May 2008
Reputation Points: 60
Solved Threads: 13
Skill Endorsements: 11

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0566 seconds using 2.74MB