2014-02-17 83 views
1

我想關閉模式對話框只需點擊十字(關閉)button.it沒有關閉時,單擊模式外。我怎麼能實現它?Twitter Bootstrap:如何僅通過關閉圖標關閉模式對話框?

$(document).ready(function() { 
      $('#windowTitleDialog').bind('show', function() { 
       document.getElementById ("xlInput").value = document.title; 
       }); 
      }); 
     function closeDialog() { 
      $('#windowTitleDialog').modal('hide'); 
      }; 
     function okClicked() { 
      document.title = document.getElementById ("xlInput").value; 
      closeDialog(); 
      }; 
+0

的屬性,你可以創建一個小提琴? – Felix

回答

0

看的文檔:http://getbootstrap.com/javascript/#modals-usage

提取物:

$('#myModal').modal(options) 

選項:

背景:包括一個模式,背景元素。或者,指定 靜態爲不會在點擊時關閉模式的背景。

鍵盤:關閉時退出鍵被按下

所以只需要調用模式:

$('#myModal').modal(
    { 
     backdrop: 'static', 
     keyboard: false 
    } 
); 
1

沒有必要在這裏的任何腳本。如果你正在使用Twitter的引導3,只需添加

data-backdrop="false" 

添加這樣

<button class="btn btn-primary" data-backdrop="false" data-toggle="modal" data-target=".bs-example-modal-lg">Large modal</button>