});
test( "jQuery usage", function() {
- expect( 10 );
+ expect( 11 );
- var shouldInit = false;
+ var shouldCreate = false;
$.widget( "ui.testWidget", {
getterSetterVal: 5,
_create: function() {
- ok( shouldInit, "init called on instantiation" );
+ ok( shouldCreate, "create called on instantiation" );
},
methodWithParams: function( param1, param2 ) {
ok( true, "method called via .pluginName(methodName)" );
}
});
- shouldInit = true;
- var elem = $( "<div></div>" ).testWidget();
- shouldInit = false;
+ shouldCreate = true;
+ var elem = $( "<div></div>" )
+ .bind( "testwidgetcreate", function() {
+ ok( shouldCreate, "create event triggered on instantiation" );
+ })
+ .testWidget();
+ shouldCreate = false;
var instance = elem.data( "testWidget" );
equals( typeof instance, "object", "instance stored in .data(pluginName)" );
test( "direct usage", function() {
expect( 9 );
- var shouldInit = false;
+ var shouldCreate = false;
$.widget( "ui.testWidget", {
getterSetterVal: 5,
_create: function() {
- ok( shouldInit, "init called on instantiation" );
+ ok( shouldCreate, "create called on instantiation" );
},
methodWithParams: function( param1, param2 ) {
ok( true, "method called dirctly" );
var elem = $( "<div></div>" )[ 0 ];
- shouldInit = true;
+ shouldCreate = true;
var instance = new $.ui.testWidget( {}, elem );
- shouldInit = false;
+ shouldCreate = false;
equals( $( elem ).data( "testWidget" ), instance,
"instance stored in .data(pluginName)" );