I really like the JavaScript module pattern to encapsulate data and logic. I'm also using jQuery extensively. My question is this:
If I define a jQuery extension/plug-in WITHIN a module, will it be local to that module like other functions would be? (I suspect the answer is no...)
Example:
var igPartListManager = (function () {
// Define a jQuery plug-in I'd like to be local to igPartListManager
(function ($) {
$.fn.myExtension = function () {
// Do something with this.each()...
}
})(jQuery);
var doSomethingCore = function () {
// Use my jQuery plug-in
$("selector").myExtension();
};
return {
doSomething
: doSomethingCore
};
})();
Outside of igPartListManager, would this succeed?
...
$("some_unrelated_selector").myExtension();
If it does, how do I best encapsulate 'local' jQuery-extension/plug-in-like functionality within a module?