Core: Added radio/checkbox to delegate click-event

Reverts the accidental change from d319a0da35,
where these event handlers were dropped.

Closes #1126
This commit is contained in:
Lars Laade
2014-05-23 12:18:27 +02:00
committed by Jörn Zaefferer
parent db55d36de5
commit cda5efa487
2 changed files with 32 additions and 1 deletions

View File

@@ -349,7 +349,7 @@ $.extend( $.validator, {
"focusin focusout keyup", delegate)
// Support: Chrome, oldIE
// "select" is provided as event.target when clicking a option
.validateDelegate("select, option", "click", delegate);
.validateDelegate("select, option, [type='radio'], [type='checkbox']", "click", delegate);
if ( this.settings.invalidHandler ) {
$( this.currentForm ).bind( "invalid-form.validate", this.settings.invalidHandler );

View File

@@ -364,6 +364,37 @@ asyncTest("validation triggered on radio/checkbox when using keyboard", function
}, 50);
});
asyncTest("validation triggered on radio/checkbox when using mouseclick", function() {
expect( 1 );
var input, i, events, triggeredEvents = 0;
$("#form").validate({
onclick: function() {
triggeredEvents++;
}
});
events = [
$.Event("click")
];
input = $("#form :radio:first");
for(i = 0; i < events.length; i++) {
input.trigger(events[i]);
}
input = $("#form :checkbox:first");
for(i = 0; i < events.length; i++) {
input.trigger(events[i]);
}
setTimeout(function() {
// assert all event handlers fired
equal(2, triggeredEvents);
start();
}, 50);
});
test( "showErrors()", function() {
expect( 4 );
var errorLabel = $( "#errorFirstname" ).hide(),