assertClasses(":eq(0)", ":eq(1)", ":eq(2)");
// click outside of forms
- $("#radio0 .ui-button:eq(1)").click();
+ $("#radio0 .ui-button:eq(1)").trigger( "click" );
assertClasses(":eq(1)", ":eq(1)", ":eq(2)");
// click in first form
- $("#radio1 .ui-button:eq(0)").click();
+ $("#radio1 .ui-button:eq(0)").trigger( "click" );
assertClasses(":eq(1)", ":eq(0)", ":eq(2)");
// click in second form
- $("#radio2 .ui-button:eq(0)").click();
+ $("#radio2 .ui-button:eq(0)").trigger( "click" );
assertClasses(":eq(1)", ":eq(0)", ":eq(0)");
});
asyncTest( "ensure checked and aria after single click on checkbox label button, see #5518", function( assert ) {
expect( 3 );
- $("#check2").button().change( function() {
+ $("#check2").button().on( "change", function() {
var lbl = $( this ).button("widget");
ok( this.checked, "checked ok" );
ok( lbl.attr("aria-pressed") === "true", "aria ok" );
var check = $( "#check" ).button(),
label = $( "label[for='check']" );
assert.lacksClasses( label, "ui-state-focus" );
- check.focus();
+ check.trigger( "focus" );
setTimeout(function() {
assert.hasClasses( label, "ui-state-focus" );
start();
test("buttonset works with single-quote named elements (#7505)", function() {
expect( 1 );
$("#radio3").buttonset();
- $("#radio33").click( function(){
+ $("#radio33").on( "click", function(){
ok( true, "button clicks work with single-quote named elements" );
- }).click();
+ }).trigger( "click" );
});
asyncTest( "when button loses focus, ensure active state is removed (#8559)", function( assert ) {
element.one( "blur", function() {
assert.lacksClasses( element, "ui-state-active", "button loses active state appropriately" );
start();
- }).blur();
+ }).trigger( "blur" );
});
- element.focus();
+ element.trigger( "focus" );
setTimeout(function() {
element
.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } )
},
_create: function() {
this.element.closest( "form" )
- .unbind( "reset" + this.eventNamespace )
- .bind( "reset" + this.eventNamespace, formResetHandler );
+ .off( "reset" + this.eventNamespace )
+ .on( "reset" + this.eventNamespace, formResetHandler );
if ( typeof this.options.disabled !== "boolean" ) {
this.options.disabled = !!this.element.prop( "disabled" );
this.buttonElement
.addClass( baseClasses )
.attr( "role", "button" )
- .bind( "mouseenter" + this.eventNamespace, function() {
+ .on( "mouseenter" + this.eventNamespace, function() {
if ( options.disabled ) {
return;
}
$( this ).addClass( "ui-state-active" );
}
})
- .bind( "mouseleave" + this.eventNamespace, function() {
+ .on( "mouseleave" + this.eventNamespace, function() {
if ( options.disabled ) {
return;
}
$( this ).removeClass( activeClass );
})
- .bind( "click" + this.eventNamespace, function( event ) {
+ .on( "click" + this.eventNamespace, function( event ) {
if ( options.disabled ) {
event.preventDefault();
event.stopImmediatePropagation();
});
if ( toggleButton ) {
- this.element.bind( "change" + this.eventNamespace, function() {
+ this.element.on( "change" + this.eventNamespace, function() {
that.refresh();
});
}
if ( this.type === "checkbox" ) {
- this.buttonElement.bind( "click" + this.eventNamespace, function() {
+ this.buttonElement.on( "click" + this.eventNamespace, function() {
if ( options.disabled ) {
return false;
}
});
} else if ( this.type === "radio" ) {
- this.buttonElement.bind( "click" + this.eventNamespace, function() {
+ this.buttonElement.on( "click" + this.eventNamespace, function() {
if ( options.disabled ) {
return false;
}
});
} else {
this.buttonElement
- .bind( "mousedown" + this.eventNamespace, function() {
+ .on( "mousedown" + this.eventNamespace, function() {
if ( options.disabled ) {
return false;
}
lastActive = null;
});
})
- .bind( "mouseup" + this.eventNamespace, function() {
+ .on( "mouseup" + this.eventNamespace, function() {
if ( options.disabled ) {
return false;
}
$( this ).removeClass( "ui-state-active" );
})
- .bind( "keydown" + this.eventNamespace, function(event) {
+ .on( "keydown" + this.eventNamespace, function(event) {
if ( options.disabled ) {
return false;
}
})
// see #8559, we bind to blur here in case the button element loses
// focus between keydown and keyup, it would be left in an "active" state
- .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
+ .on( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
$( this ).removeClass( "ui-state-active" );
});
if ( this.buttonElement.is("a") ) {
- this.buttonElement.keyup(function(event) {
+ this.buttonElement.on( "keyup", function(event) {
if ( event.keyCode === $.ui.keyCode.SPACE ) {
// TODO pass through original event correctly (just as 2nd argument doesn't work)
- $( this ).click();
+ $( this ).trigger( "click" );
}
});
}