To better explain this I made a little example of what actually happens when you define your extension:
(function ($) {
// $ = window.jQuery;
$.fn.myExtension = function () {
// Do something with this.each()...
}
})(window.jQuery); // Note window.jQuery is basically the same as just jQuery from your example code
Whenever you try to access a variable, the javascript engine bubbles up trough all encapsulating scopes all the way up to the window
scope. The first scope that has that variable is the scope that is being used. Since in your case the window scope holds your jQuery
variable you could call it 'global'.
When calling this $("some_unrelated_selector).myExtension();
the engine looks for the variable $
. If this variable points to window.jQuery
at that point, you are in fact using the same object as before. So yes, that would succeed in that case. But only if you executed the igPartListManager
function before trying to call $().myExtension();
.
The only way to create a local scope for your extensions is to deep copy the window.jQuery
variable to a local variable before adding extensions to it.
Example: Javascript deep copying object