diff --git a/demos/tabs/manipulation.html b/demos/tabs/manipulation.html index fc9b750b3..f7202ee48 100644 --- a/demos/tabs/manipulation.html +++ b/demos/tabs/manipulation.html @@ -48,7 +48,7 @@ }); // addTab form: calls addTab function on submit and closes the dialog - var form = dialog.find( "form" ).submit(function( event ) { + var form = dialog.find( "form" ).on( "submit", function( event ) { addTab(); dialog.dialog( "close" ); event.preventDefault(); @@ -70,18 +70,18 @@ // addTab button: just opens the dialog $( "#add_tab" ) .button() - .click(function() { + .on( "click", function() { dialog.dialog( "open" ); }); // close icon: removing the tab on click - tabs.delegate( "span.ui-icon-close", "click", function() { + tabs.on( "click", "span.ui-icon-close", function() { var panelId = $( this ).closest( "li" ).remove().attr( "aria-controls" ); $( "#" + panelId ).remove(); tabs.tabs( "refresh" ); }); - tabs.bind( "keyup", function( event ) { + tabs.on( "keyup", function( event ) { if ( event.altKey && event.keyCode === $.ui.keyCode.BACKSPACE ) { var panelId = tabs.find( ".ui-tabs-active" ).remove().attr( "aria-controls" ); $( "#" + panelId ).remove(); diff --git a/tests/unit/tabs/events.js b/tests/unit/tabs/events.js index ec2f61214..d54d47926 100644 --- a/tests/unit/tabs/events.js +++ b/tests/unit/tabs/events.js @@ -85,7 +85,7 @@ test( "beforeActivate", function() { strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" ); state( element, 1, 0, 0 ); }); - anchors.eq( 1 ).click(); + anchors.eq( 1 ).trigger( "click" ); state( element, 0, 1, 0 ); // collapsing @@ -156,7 +156,7 @@ test( "activate", function() { strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" ); state( element, 0, 1, 0 ); }); - anchors.eq( 1 ).click(); + anchors.eq( 1 ).trigger( "click" ); state( element, 0, 1, 0 ); // collapsing @@ -251,7 +251,7 @@ test( "beforeLoad", function() { event.preventDefault(); state( element, 0, 0, 1, 0, 0 ); }); - element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 3 ).click(); + element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 3 ).trigger( "click" ); state( element, 0, 0, 0, 1, 0 ); // .toLowerCase() is needed to convert
to
in old IEs equal( panel.html().toLowerCase(), "
testing
", "panel html after" ); @@ -315,7 +315,7 @@ asyncTest( "load", function() { state( element, 0, 0, 0, 0, 1 ); start(); }); - element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 4 ).click(); + element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 4 ).trigger( "click" ); } }); diff --git a/tests/unit/tabs/options.js b/tests/unit/tabs/options.js index e1a663a71..dc1a03505 100644 --- a/tests/unit/tabs/options.js +++ b/tests/unit/tabs/options.js @@ -68,7 +68,7 @@ test( "{ active: Number }", function() { equal( element.tabs( "option", "active" ), 0 ); state( element, 1, 0, 0 ); - element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).click(); + element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "click" ); equal( element.tabs( "option", "active" ), 1 ); state( element, 0, 1, 0 ); @@ -127,7 +127,7 @@ test( "collapsible", function( assert ) { equal( element.tabs( "option", "active" ), 1 ); state( element, 0, 1, 0 ); - element.find( ".ui-state-active .ui-tabs-anchor" ).click(); + element.find( ".ui-state-active .ui-tabs-anchor" ).trigger( "click" ); equal( element.tabs( "option", "active" ), false ); state( element, 0, 0, 0 ); @@ -146,7 +146,7 @@ test( "collapsible", function( assert ) { equal( element.tabs( "option", "active" ), 1 ); state( element, 0, 1, 0 ); - element.find( ".ui-state-active .ui-tabs-anchor" ).eq( 1 ).click(); + element.find( ".ui-state-active .ui-tabs-anchor" ).eq( 1 ).trigger( "click" ); equal( element.tabs( "option", "active" ), 1 ); state( element, 0, 1, 0 ); @@ -210,7 +210,7 @@ test( "{ event: null }", function() { state( element, 0, 1, 0 ); // ensure default click handler isn't bound - element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).click(); + element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "click" ); equal( element.tabs( "option", "active" ), 1 ); state( element, 0, 1, 0 ); }); diff --git a/ui/tabs.js b/ui/tabs.js index 3bd7b9246..f267ad4bf 100644 --- a/ui/tabs.js +++ b/ui/tabs.js @@ -233,7 +233,7 @@ $.widget( "ui.tabs", { // Ctrl+up moves focus to the current tab if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) { event.preventDefault(); - this.active.focus(); + this.active.trigger( "focus" ); } }, @@ -271,7 +271,7 @@ $.widget( "ui.tabs", { _focusNextTab: function( index, goingForward ) { index = this._findNextTab( index, goingForward ); - this.tabs.eq( index ).focus(); + this.tabs.eq( index ).trigger( "focus" ); return index; }, @@ -394,7 +394,7 @@ $.widget( "ui.tabs", { // Prevent users from focusing disabled tabs via click this.tablist - .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) { + .on( "mousedown" + this.eventNamespace, "> li", function( event ) { if ( $( this ).is( ".ui-state-disabled" ) ) { event.preventDefault(); } @@ -406,7 +406,7 @@ $.widget( "ui.tabs", { // We don't have to worry about focusing the previously focused // element since clicking on a non-focusable element should focus // the body anyway. - .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() { + .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() { if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) { this.blur(); } @@ -726,7 +726,7 @@ $.widget( "ui.tabs", { this.tablist .removeAttr( "role" ) - .unbind( this.eventNamespace ); + .off( this.eventNamespace ); this.anchors .removeAttr( "role tabIndex" )