Hi,
After using jQuery for a long time now I have a question, I'm writing a simple code using the jQuery pattern(style),
(function(window, undefined) {
var jQuery = function (s, c) { ... }
}) (window);
As we all know jQuery is defined in a self Executing anonymous function, I guess its scope (jQuery) should be restricted to that anonymous function, but how do we have access to the jQuery outside the anonymous method ? If my assumption is wrong... Please Correct me.
I tried to write a code something similar to jQuery passion i.e., wrapping up my entire code in an anonymous method, like
(function( w, u ) {
var JS = function() { return JS.fn.init();};
JS.fn = JS.prototype = {
init : function () {
alert('Initiated');
return this;
}
};
}) (window);
When I tried to call JS().init();
I'm getting an error in my firebug console saying that JS is not defined
. Where I'm going wrong? Is it due to the scope limitation or poorly written code ?