mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Widget factory: Fixed #3275: Prevent multiple instantiations of the same plugin on a single element.
This commit is contained in:
parent
b95772ef09
commit
ccdb99e313
@ -89,11 +89,14 @@ $.widget = function(name, prototype) {
|
|||||||
// handle initialization and non-getter methods
|
// handle initialization and non-getter methods
|
||||||
return this.each(function() {
|
return this.each(function() {
|
||||||
var instance = $.data(this, name);
|
var instance = $.data(this, name);
|
||||||
if (isMethodCall && instance && $.isFunction(instance[options])) {
|
|
||||||
instance[options].apply(instance, args);
|
// constructor
|
||||||
} else if (!isMethodCall) {
|
(!instance && !isMethodCall &&
|
||||||
$.data(this, name, new $[namespace][name](this, options));
|
$.data(this, name, new $[namespace][name](this, options)));
|
||||||
}
|
|
||||||
|
// method call
|
||||||
|
(instance && isMethodCall &&
|
||||||
|
instance[options].apply(instance, args));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user