diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index dbfea257422..2aef8f96a5b 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -90,7 +90,7 @@ $.widget.bridge = function( name, object ) { options; // prevent calls to internal methods - if ( isMethodCall && options.substring( 0, 1 ) === "_" ) { + if ( isMethodCall && options.charAt( 0 ) === "_" ) { return returnValue; } @@ -98,8 +98,8 @@ $.widget.bridge = function( name, object ) { this.each(function() { var instance = $.data( this, name ); if ( !instance ) { - throw "cannot call methods on " + name + " prior to initialization; " + - "attempted to call method '" + options + "'"; + // allow lazy initialization + instance = $.data( this, name, new object( null, this )); } if ( !$.isFunction( instance[options] ) ) { throw "no such method '" + options + "' for " + name + " widget instance";