Widget factory: fixed #2981: Graceful handling of method calls on uninitialized plugins.

This commit is contained in:
Scott González 2008-06-04 22:03:17 +00:00
parent 126d7d925b
commit 2b1bd34cef

View File

@ -101,10 +101,10 @@ $.widget = function(name, prototype) {
return this.each(function() { return this.each(function() {
var instance = $.data(this, name); var instance = $.data(this, name);
if (!instance) { if (isMethodCall && instance) {
$.data(this, name, new $[namespace][name](this, options));
} else if (isMethodCall) {
instance[options].apply(instance, args); instance[options].apply(instance, args);
} else if (!isMethodCall) {
$.data(this, name, new $[namespace][name](this, options));
} }
}); });
}; };