私はAjaxを使ってモーダルウィンドウ内に何かを挿入したいので、モーダルウィンドウを手動で開こうとしました。コードは、HTMLを直接ブートストラップjsのページTwitter Bootstrapモーダルウィンドウがちらつく
<div id="modal-from-dom" class="modal hide fade">
<div class="modal-header">
<a href="#" class="close">×</a>
<h3>Modal Heading</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<a href="#" class="btn primary">Primary</a>
<a href="#" class="btn secondary">Secondary</a>
</div>
</div>
<button id="modalbutton" class="btn">Launch Modal</button>
からコピーされたこの
$(function(){
$('#modal-from-dom').modal({
backdrop: true,
keyboard: true
});
$('#modalbutton').click(function(){
$('#my-modal').bind('show', function() {
// do sth with the modal
});
$('#modal-from-dom').modal('toggle');
return false;
});
});
のように見えるので、問題は、モーダルをクリック秒後、最初の時間だけで正常に動作するようです]ボタンをクリックしていますウィンドウが1秒間表示されて消えます。 '表示'に切り替えると、2回目のクリック後に背景が完全にフェードアウトしません。これをどのようにデバッグできますか?
は '.modal()ある種の'プラグインですか? '#my-modal'とは何ですか?あなたは何をしていますか?おそらく問題は、あなたがクリックごとに 'show'イベントをバインドしていることです。それはあなたのトグルをねじ込む何かをします。 –
この質問は締め切られました。私は質問のコードを更新しました。 – shenyl
解決策を投稿してください。 – JSuar