| using jQuery.noConflict()
|
sssweb

msg:4413531 | 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?
|
daveVk

msg:4414141 | 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.
|
sssweb

msg:4414200 | 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.
|
daveVk

msg:4414376 | 2:08 am on Feb 5, 2012 (gmt 0) | See [svennerberg.com...] or search "global variables javascript". Take the jQuery function inArray as an example, there could have placed it in the global namespace such that you would call inArray('spot',dogs) instead it is within the jQuery object jQuery.inArray('spot',dogs) and will not conflict with other libraries offering similar function.
|
|
|