[英]Bootstrap Dynamic Modal
我一直在嘗試使用twitter引導程序執行動態模態,如下所示:
$('#myModal').on('hide', function () {
$(this).removeData('modal');
$('.loading-modal').remove();
})
每次我單擊按鈕時,它都會在模態中重新加載數據,但是...
我注意到的是,在關閉預覽模式后,當我打開下一個模式時,仍然顯示預覽數據,並在幾秒鍾后使用新數據進行更新。
我想要的是每次調用模態時都會將數據設置為“正在加載...”,然后顯示新數據。
如何做到這一點? 還是有更好的方法?
更新
這就是我使用data-remove=
調用模式的遠程數據的方式
<a href="" role="button" data-target="#myModal" data-toggle="modal" data-backdrop="static" data-remote="/manager/test/{{ $donator->USERNO }}"><i class="icon-plus"></i></a>
模態
<!-- Modal -->
<div id="myModal" 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">×</button>
<h3 id="myModalLabel">Editing Data</h3>
</div>
<div class="modal-body">
<div class="loading-modal">Loading...</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
我使用Ajax做過類似的事情,不確定這是否是“最佳”方法,但是它可以工作。
只需將常規按鈕/超鏈接與Javascript函數調用配合使用即可:
<button class="btn" onclick="showDialog()">Click Me</button>
然后在函數內部顯示對話框並執行ajax調用:
function showDialog() {
$("#dialogBody").html("Loading..."); // Or use a progress bar...
$("#dialog").modal("show");
$.ajax({
url: myUrl.com,
}).success(function(data) {
$("#dialogBody").html(data);
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.