From ccdb99e313edc48f423c6ec75a052e8f8d268268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 2 Sep 2008 23:34:42 +0000 Subject: [PATCH] Widget factory: Fixed #3275: Prevent multiple instantiations of the same plugin on a single element. --- ui/ui.core.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ui/ui.core.js b/ui/ui.core.js index 3d78c973a..22597bf9d 100644 --- a/ui/ui.core.js +++ b/ui/ui.core.js @@ -89,11 +89,14 @@ $.widget = function(name, prototype) { // handle initialization and non-getter methods return this.each(function() { var instance = $.data(this, name); - if (isMethodCall && instance && $.isFunction(instance[options])) { - instance[options].apply(instance, args); - } else if (!isMethodCall) { - $.data(this, name, new $[namespace][name](this, options)); - } + + // constructor + (!instance && !isMethodCall && + $.data(this, name, new $[namespace][name](this, options))); + + // method call + (instance && isMethodCall && + instance[options].apply(instance, args)); }); };