From 988cdd5dbc8422f9701a10021b9b54add5ed6026 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 15 Jan 2010 21:09:32 +0000 Subject: Widget: Make subsequent "init" calls useful by delegating to the option and _init methods. Fixes #5064 - Widget: make multiple instantiation more useful. --- ui/jquery.ui.widget.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index a89426347..a73df800f 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -93,7 +93,13 @@ $.widget.bridge = function( name, object ) { }); } else { this.each(function() { - if ( !$.data( this, name ) ) { + var instance = $.data( this, name ); + if ( instance ) { + if ( options ) { + instance.option( options ); + } + instance._init(); + } else { $.data( this, name, new object( options, this ) ); } }); @@ -132,13 +138,11 @@ $.Widget.prototype = { self.destroy(); }); - if ( this._create ) { - this._create( options, element ); - } - if ( this._init ) { - this._init(); - } + this._create( options, element ); + this._init(); }, + _create: function() {}, + _init: function() {}, destroy: function() { this.element -- cgit v1.2.3