core widget - fail gracefully if unknown method name supplied

This commit is contained in:
Richard Worth 2008-06-08 00:55:44 +00:00
parent 7539a095f6
commit e23a0edb70

View File

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