bootstrap-multiselect onDropdownShow doesn't work

Using davidstutz's bootstrap-multiselect plugin with twitter bootstrap 3.3.0. 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):

{{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:

$(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. I removed first one and it worked like a charm.

Answers:

Answer

Its onDropdownShown not onDropdownShow

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

Source

Answer

try Each operation like this :

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

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.