title: Select values in bootstrap multiselect based on data attributes in jquery
body: <p>I'm rather new in jquery/bootstrap coding and want to achieve the following. I have a select (using bootstrap Multiselect) with several options. Within this list, I try to select all the options that match values of an array (list1 in below code). However, instead of looking at the value op the options, I need to check on a data-attribute of the option (list 2 in below code). </p>
  
  <p><strong>My dropdown</strong></p>
  
  <pre><code>&lt;form&gt;
    &lt;select class="form-control" id="list1" multiple="multiple"&gt;
      &lt;option data-vendorid="001" value="001"&gt;some-value-1&lt;/option&gt;
      &lt;option data-vendorid="002" value="002"&gt;some-value-2&lt;/option&gt;
      &lt;option data-vendorid="003" value="003"&gt;some-value-3&lt;/option&gt;
    &lt;/select&gt;
  
    &lt;select class="form-control" id="list2" multiple="multiple"&gt;
      &lt;option data-vendorid="001" value="some-value-1"&gt;some-value-1&lt;/option&gt;
      &lt;option data-vendorid="002" value="some-value-2"&gt;some-value-2&lt;/option&gt;
      &lt;option data-vendorid="003" value="some-value-3"&gt;some-value-3&lt;/option&gt;
    &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>My script</strong></p>
  
  <pre><code>var arr = [{
      "attr-1": "attr-value-1",
      "attr-2": "attr-value-2",
      "id": "001"
  }, {
      "attr-1": "attr-value-1",
      "attr-2": "attr-value-2",
      "id": "003"
  }];
  
  //If I look for the default value, it works:
  for (var i = 0; i &lt; arr.length; i++) {
      $('#list1').multiselect('select', arr[i].id);
  }
  
  //So I tried something like this, but can't figure it out
  for (var i = 0; i &lt; arr.length; i++) {
      $('#list2').multiselect('select', $(arr[i]).data('vendorid'));
  }
  </code></pre>
  
  <p>Check <a href="http://jsfiddle.net/stevenschutter/gpSqc/705/" rel="nofollow noreferrer">my updated fiddle</a>!</p>
  
  <p>Help is much appreciated</p>