2015-02-07 67 views
0

我試圖爲我的網站(Magento版本1.9.1.0)設置bootstrap-select.js,並且我遇到了一些問題解決。Bootstrap-select.js - 選擇一個選項後,整個選擇消失

一切都被載入完美的,但是當我通過獲取element.style到像這樣整個選擇消失選擇下拉列表中選擇一個選項:

style="display:none;" 

而且在Firebug它說:

element.style { 
display: none; 
} 

在這裏看到的視覺形象:http://i.imgur.com/cg1jkOp.jpg?1

的問題是我不知道這個造型是從哪裏來的,所以我決定CHEC k在FireBug中打斷屬性改變,看看它說了什麼。該代碼jQuery的(jQuery的2.1.3.min.js)之際,您可以在此圖像中看到:http://i.imgur.com/Jbu8TCx.jpg?1

這是我在我的<head>部分:

<link rel="stylesheet" href="http://localhost/sg-magento/skin/frontend/ultimo/default/css/bootstrap/bootstrap.min.css"> 
<link rel="stylesheet" href="http://localhost/sg-magento/skin/frontend/ultimo/default/css/bootstrap/bootstrap-select.min.css"> 

<script type="text/javascript" src="http://localhost/sg-magento/js/infortis/jquery/jquery-2.1.3.min.js"></script> 

<script type="text/javascript" src="http://localhost/sg-magento/skin/frontend/ultimo/default/js/bootstrap/bootstrap.min.js"></script> 
<script type="text/javascript" src="http://localhost/sg-magento/skin/frontend/ultimo/default/js/bootstrap/bootstrap-select.min.js"></script> 

<script type="text/javascript"> 
jQuery(document).ready(function($) { 
    $('.selectpicker').selectpicker(); 
}); 
</script> 

我到哪裏去從這裏?我該如何解決這個問題?看起來像是一件小事,但現在真的讓我很緊張。一直試圖找出很長一段時間。

希望有人願意嘗試幫助。

謝謝。

回答

0

我有類似的問題,當select在提交和重新呈現Backbone模板時消失。在我的情況下調用$('。selectpicker')。selectpicker('render');修復。

+0

我遲到了,但是如果您收到此通知,您是否介意告訴我您將代碼放在哪裏? – IRGeekSauce 2017-02-08 01:10:37

1

這是因爲用於Bootstrap和Prototype的衝突。查看更多詳情here。 創建一個新的JS文件並在其中添加以下代碼。

if (Prototype.BrowserFeatures.ElementExtensions) { 
var disablePrototypeJS = function (method, pluginsToDisable) { 
     var handler = function (event) { 
      event.target[method] = undefined; 
      setTimeout(function() { 
       delete event.target[method]; 
      }, 0); 
     }; 
     pluginsToDisable.each(function (plugin) { 
      jQuery(window).on(method + '.bs.' + plugin, handler); 
     }); 
    }, 
    pluginsToDisable = ['collapse', 'dropdown', 'modal', 'tooltip', 'popover']; 
disablePrototypeJS('show', pluginsToDisable); 
disablePrototypeJS('hide', pluginsToDisable);} 

玩得開心:)

0
$(".dropdown-menu > ul > li").click(function() { 
$('.bootstrap-select').attr('style', ''); 
$(this).parent('.bootstrap-select').attr('style', ''); 
}); 

這將覆蓋cuases這個問題任何衝突。我不相信以前的答案是正確的。礦山DEF不是一個答案。但它會解決問題,直到可以花更多時間找到衝突的真正根源。原型可能是原因,但原型答案不起作用!

相關問題