Reputation: 18238
I have some divs that I show/hide. I want to reset the forms inside these divs every time they are hidden, but this does not seem to work:
$('#div_id_1,#div_id_2').on('hide',function(){
$('#form_id_1,#form_id_2').each(function(){
this.reset();
});
});
This function never gets triggered. How to I capture this "hide" event?
Thanks
Upvotes: 0
Views: 1774
Reputation: 160963
You need trigger the hide
event manually.
$('#div_id_1').hide('fast', function() {
$(this).trigger('hide');
});
Upvotes: 0
Reputation: 30452
You would need to either put your reset code in the place where you actually do the hiding, or simply trigger a 'hide' event yourself:
$('#somelink').click( function() {
$('#div_id_1').hide().trigger('hide');
} );
This is because there is no hide
event triggered by jQuery itself (see docs).
Upvotes: 2