ahm*_*bri 5 jquery modal-dialog twitter-bootstrap
我正在使用Twitter引导程序模式从表中加载数据.
这是我的HTML代码.
<tr>
....
<td> <a href="http://google.com">Text</a> </td>
....
</tr>
Run Code Online (Sandbox Code Playgroud)
这就是页面末尾的Modal div
<div id="modal"></div>
Run Code Online (Sandbox Code Playgroud)
我想要实现的是通过单击要更新的模态内容的单元格内的链接,然后在完成更新后自动打开模态.这是我试过的.
$('td').on('click','a',function(){
var href = $(this).attr('href');
$('#modal').load(href,function(){
$(this).modal({
keyboard:true,
backdrop:true
});
});
Run Code Online (Sandbox Code Playgroud)
它没有给我任何错误,实际上HTML在Modal div中成功加载但是在更新HTML之后它没有加载模态它需要另一个"点击"?!我不知道为什么?
这对我有用:
$('div#modal').load(url,function(){
$(this).modal({
keyboard:true,
backdrop:true
});
}).modal('show');
Run Code Online (Sandbox Code Playgroud)
但是提供的URL应该输出一个正确的模态,如下所示:
<div class="modal" id="myModal">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<a href="#" class="btn">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)