From 2b1bd34cef6a5e80555b5ff82acd8ddc25d6d3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 4 Jun 2008 22:03:17 +0000 Subject: [PATCH] Widget factory: fixed #2981: Graceful handling of method calls on uninitialized plugins. --- ui/source/ui.core.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/source/ui.core.js b/ui/source/ui.core.js index aa3c9f464..aff49eeda 100644 --- a/ui/source/ui.core.js +++ b/ui/source/ui.core.js @@ -101,10 +101,10 @@ $.widget = function(name, prototype) { return this.each(function() { var instance = $.data(this, name); - if (!instance) { - $.data(this, name, new $[namespace][name](this, options)); - } else if (isMethodCall) { + if (isMethodCall && instance) { instance[options].apply(instance, args); + } else if (!isMethodCall) { + $.data(this, name, new $[namespace][name](this, options)); } }); };