[英]Bind a function to Twitter Bootstrap Modal Ajax Complete
I use this for Bootstrap Modal: 我将它用于Bootstrap Modal:
<a href="one/url" data-target="#add-follow-up-modal" role="button" class="btn" data-toggle="modal">
Load
</a>
<div id="add-follow-up-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-body">
<p>Please wait…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
Now, i want to run a function when ajax load completed. 现在,我想在ajax加载完成时运行一个函数。
Any idea? 任何想法?
By default bootstrap modal does not trigger an event for ajax load, you can have a look at the list of triggered events at the modal section of the bootstrap documentation . 默认情况下,bootstrap模式不会触发ajax加载的事件,您可以查看引导文档的模态部分中的触发事件列表。
What you can do, however is to write your own function that loads the content to the modal's body via ajax, and attach a .done() to it. 但是,您可以编写自己的函数,通过ajax将内容加载到模态的主体,并将.done()附加到它上面。
remove href from your link 从链接中删除href
in ajax success add href="one/url"
to your "a" attributes and then trigger click on your link 在ajax成功中将href="one/url"
到您的“a”属性中,然后触发点击您的链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.