Linked Questions

Popular Questions

Limit the Jquery select2 maximum selected options

Asked by At

I have refered to this docs provided by select2 jquery plugin.

But when I use this code to limit the number of options a user can select at a time:

    $(".select2").select2({ maximumSelectionSize: 2 });

And here is the html of select tag:

  <select id="store-name" name="state[]" class="select2-select-00 span6" multiple size="5"
            data-placeholder="Store" style="height:25px;">

        <?php foreach ($this->Store->get_all_stores_names() as $row) {

          echo '<option value="' . $row->name . '"> ' . $row->name . '</option>';


When i try to limit it , I get this error in console, "Uncaught TypeError: Object [object Object] has no method 'select2' ". Why? I mean the select2 works fine which means that it's js files are being loaded,then why I am unable to limit it? Thanks

Related Questions