title: Limit the jQuery select2 maximum selected options
body: <p>I have referred to this docs provided by select2 jQuery plugin. 
  <a href="http://ivaynberg.github.io/select2/" rel="nofollow noreferrer">http://ivaynberg.github.io/select2/</a></p>
  
  <p>But when I use this code to limit the number of options a user can select at a time:</p>
  
  <pre><code>$(document).ready(function(){
      $(".select2").select2({ maximumSelectionSize: 2 });
      });
  </code></pre>
  
  <p>And here is the html of select tag:</p>
  
  <pre><code>  &lt;select id="store-name" name="state[]" class="select2-select-00 span6" multiple size="5"
              data-placeholder="Store" style="height:25px;"&gt;
  
  
          &lt;?php foreach ($this-&gt;Store-&gt;get_all_stores_names() as $row) {
  
          //print_r($row);
            echo '&lt;option value="' . $row-&gt;name . '"&gt; ' . $row-&gt;name . '&lt;/option&gt;';
          }
          ?&gt;
  
      &lt;/select&gt;
  </code></pre>
  
  <p>When I try to limit it, I get this error in console:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Object [object Object] has no method 'select2'</p>
  </blockquote>
  
  <p>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?</p>