skip to Main Content

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.

2

Answers


  1. Its onDropdownShown not onDropdownShow

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

    Source

    Login or Signup to reply.
  2. try Each operation like this :

    $('#selectID').multiselect({
            onDropdownShown: function(event){
                      $('#selectID option').each(function () {
                             var rad = $(this).find('#radioID')[0];
                             $(rad).prop('checked', true);
                     }
            }
        });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search