bootstrap 2.3.2在同一个页面使用多个弹出对话框时,点击几次之后弹出框会消失和不可用。



<h3>This button shows a modal (<code>#utility</code>) with text "Phasellus <em>tincidunt gravida</em>..."</h3>
<br />
<a id="file_attach" data-toggle="modal" href="" data-target="#utility" class="btn">Modal 1</a><br />
<h3>This button should invoke the same modal (<code>#utility</code>), but fill it with text "Phasellus <em>egestas est eu</em>..."</h3>
<br />
<a id="file_attach" data-toggle="modal" href="" data-target="#utility" class="btn">Modal 2</a><br />

<!-- Modal -->
<div id="utility" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h3 id="myModalLabel">Click outside modal to close it</h3>
  <div class="modal-body">
    <p>One fine body…this is getting replaced with content that comes from passed-in href</p>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary">Save changes</button>
$('a[data-toggle="modal"]').on('click', function(){ // update modal header with contents of button that invoked the modal $('#myModalLabel').html( $(this).html() ); //fixes a bootstrap bug that prevents a modal from being reused $('#utility_body').load( $(this).attr('href'), function(response, status, xhr) { if (status === 'error') { //console.log('got here'); $('#utility_body').html('<h2>Oh boy</h2><p>Sorry, but there was an error:' + xhr.status + ' ' + xhr.statusText+ '</p>'); } return this; } ); });​

演示 来源


订阅周报 关注微博

原创文章:bootstrap模态对话框多个弹出框bug修复 ,未经许可,禁止转载,©版权所有
原文出处:前端开发博客 (