简体   繁体   English

bootstrap-multiselect onDropdownShow不起作用

[英]bootstrap-multiselect onDropdownShow doesn't work

Using davidstutz's bootstrap-multiselect plugin with twitter bootstrap 3.3.0. 使用davidstutz的bootstrap-multiselect插件和twitter bootstrap 3.3.0。 http://davidstutz.github.io/bootstrap-multiselect http://davidstutz.github.io/bootstrap-multiselect

My purpose is that when i click on the dropdown, i'd like to get a radio button selected, but it doesn't work. 我的目的是当我点击下拉列表时,我想选择一个单选按钮,但它不起作用。

HTML (blade): HTML(刀片):

{{Form::radio('radio', 'value', null, array('id' => 'radioID' ,'class' => 'name', 'autocomplete' => 'off'))}}

{{Form::select('select', $valuesArray,'', array('id' => 'selectID' ,'multiselect' => 'multiselect', 'class' => 'msdropdown', 'multiple' => 'multiple', 'autocomplete' => 'off'))}}

JS: JS:

$(document).ready(function(){
    $('#selectID').multiselect({
        onDropdownShow: function(event){
            $('#radioID').prop('checked', true);
        }
    });
});

Thanks in advance. 提前致谢。

------------Update------------- ------------更新-------------

The problem was it was duplicately initialized, before the ('#selectID') section. 问题是它是在('#selectID')部分之前重复初始化的。 I removed first one and it worked like a charm. 我删除了第一个,它就像一个魅力。

Its onDropdownShown not onDropdownShow 它的onDropdownShown不是onDropdownShow

$(document).ready(function(){
    $('#selectID').multiselect({
        onDropdownShown: function(event){
            $('#radioID').prop('checked', true);
        }
    });
});

Source

try Each operation like this : 尝试这样的每个操作:

$('#selectID').multiselect({
        onDropdownShown: function(event){
                  $('#selectID option').each(function () {
                         var rad = $(this).find('#radioID')[0];
                         $(rad).prop('checked', true);
                 }
        }
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM