| Welcome to WebmasterWorld Guest from 220.127.116.11 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
| 2:57 pm on Feb 2, 2012 (gmt 0)|
I just discovered jQuery.noConflict() and have some questions about its use.
If I put it on my main page, then later reference an external script, do I need to use jQuery.noConflict() in that script too, or does the main page take care of it?
A more general question is: are external scripts basically independent of the calling page except for direct function calls to them?
| 4:32 am on Feb 4, 2012 (gmt 0)|
All scripts shares the global namespace, so no independence, that said good practice minimizes use of this namespace. jQuery only uses $ and jQuery I think.
jQuery.noConflict() needs to be called after jQuery installed to undo $ assignment, hopefully nothing else changes it, or other library script is executed prior to this call.
| 12:10 pm on Feb 4, 2012 (gmt 0)|
I don't understand what you mean by "good practice minimizes use of this namespace". Give me an example using jQuery.noConflict() that achieves this.
| 2:08 am on Feb 5, 2012 (gmt 0)|
Take the jQuery function inArray as an example, there could have placed it in the global namespace such that you would call
instead it is within the jQuery object
and will not conflict with other libraries offering similar function.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved