我正在使用bootstrap3加載多個外部模態。當我在不同的模態之間切換時,我遇到了最後一個模態的內容。我遇到的另一個問題是,用於加載第一模式後某種原因close
按鈕得到我已經嘗試使用不同的id tags
和工作正常,但後來我最終的modal divs
負載停用多個外部模態問題 - 引導3
<a href="#myModal" role="button" class="btn" data-toggle="modal"
data-load-remote="contact/contact.html" data-isloaded="false"
data-remote-target="#myModal">CONTACT</a>
<a href="#myModal" role="button" class="btn" data-toggle="modal"
data-load-remote="faq/faq.html" data-isloaded="false"
data-remote-target="#myModal">FAQ</a>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" arialabelledby="Label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
$(function() {
$('[data-load-remote]').on('click',function(e) {
e.preventDefault();
var $this = $(this);
var remote = $this.data('load-remote');
if (!$this.data('isloaded')) {
if(remote) {
$($this.data('remote-target')).load(remote);
$this.data('isloaded', true)
}
}
});
});
。有沒有什麼辦法可以使用相同的div
多個modals
?任何人?
這裏是一個FIDDLE不加載模式在所有:(
乾杯
您可能需要在打開新模式前關閉舊模式。 –
是的,因爲按鈕位於主畫布上,而模式位於頂部 - 通過切換,我的意思是關閉並打開一個新的 – no0ne
好的。你的意思是最後一個模態的內容保持在模態中?加載方法實際上可能附加內容可能是可能的嗎?模態HTML對於所有模態都是相同的。加載前嘗試清空'.modal-content'。 –