admin管理员组文章数量:1410730
I have a twitter bootstrap modal which I create with the data-tags so no actual javascript.
When I click outside the modal dialog (so on the grey area) it closes, but I want to make sure the fields that are in it are cleared.
I tried it with jQuery like so:
$('#modal-form > .modal-dialog').on('blur', function(){
Utils.clearFields();
});
But I never e in the anonymous function, am I binding the wrong event? Or am I using the wrong selector (I also tried it with "$('#modal-form')")?
Any help on this is highly appreciated.
Thanks
I have a twitter bootstrap modal which I create with the data-tags so no actual javascript.
When I click outside the modal dialog (so on the grey area) it closes, but I want to make sure the fields that are in it are cleared.
I tried it with jQuery like so:
$('#modal-form > .modal-dialog').on('blur', function(){
Utils.clearFields();
});
But I never e in the anonymous function, am I binding the wrong event? Or am I using the wrong selector (I also tried it with "$('#modal-form')")?
Any help on this is highly appreciated.
Thanks
Share Improve this question asked Oct 3, 2013 at 8:51 J.PipJ.Pip 4,6337 gold badges34 silver badges54 bronze badges1 Answer
Reset to default 6Version 2.3.2 and below
The event handler needs to be placed on hide
for version Bootstrap version 2.3.2 and lower
$('#modal-form > .modal-dialog').on('hide', function(){
Utils.clearFields();
});
If #modal-form
has the modal data attributes applied the selector needs modified too:
$('#modal-form').on('hide', function(){
Utils.clearFields();
});
Documentation http://getbootstrap./2.3.2/javascript.html#modals
Version 3.0
The event handler needs to be placed on hide.bs.modal
for version Bootstrap version 3.0:
$("#modal-form").on("hide.bs.modal", function(){
alert("hiding");
});
Version 3.0 Fiddle: http://jsfiddle/9u5MQ/
Version 3.0 Documentation: http://getbootstrap./javascript/#modals
本文标签: javascriptfire event when losing focus on bootstrapmodalStack Overflow
版权声明:本文标题:javascript - fire event when losing focus on bootstrap-modal - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745033078a2638617.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论