2012-09-14 48 views

回答

3

當你點擊第二個下拉按鈕,jQuery插件「自舉dropdown.js」隱藏所有元素與一流的「開放」。

您需要編輯文件「bootstrap-dropdown.js」(http://twitter.github.com/bootstrap/assets/js/bootstrap-dropdown.js)並重寫函數clearMenus()。

查找下一個代碼在這個文件中:

function clearMenus() { 
    getParent($(toggle)) 
     .removeClass('open') 
} 

,取而代之的是:

, toggle: function (e) { 
    var $this = $(this) 
    , $parent 
    , isActive 

    if ($this.is('.disabled, :disabled')) return 

    $parent = getParent($this) 

    isActive = $parent.hasClass('open') 

    clearMenus() // here 

替換線clearMenus()clearMenus($this)

function clearMenus($this) { 
    getParent($this) 
     .removeClass('open') 
} 

附近查找行clearMenus()。

這裏的jsfiddle例如:http://jsfiddle.net/BMBc3/

+0

謝謝你的信息和修復。如果我改變這一點,我會看到任何不利影響? – Darren

+0

我沒有測試這麼深的代碼:)在它的表面上,沒有。 – doktorgradus