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?

2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by riahc3
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".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.