title: Selectize.js: Prepopulate items from database selectize multiselect
body: <p>I have looked far and wide for examples on how to do this. </p>
  
  <p>I am trying to prepopulate items from a database into a select element using the Selectize jQuery plugin. The idea is that the user has previously selected item(s) and comes to this page to edit or add more items.</p>
  
  <p>From what I can tell, you populate an array using the "<a href="https://github.com/brianreavis/selectize.js/blob/master/docs/usage.md#callbacks" rel="nofollow">items</a>" option. I have had zero success trying to get this to work.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$('#nsn').selectize({
      persist: false,
      maxItems: null,
      valueField: 'id',
      labelField: 'name',
      searchField: ['nsn', 'part_name', 'id'],
      sortField: [
          {field: 'nsn', direction: 'asc'},
          {field: 'part_name', direction: 'asc'}
      ],
  //"items" below should pre-populate select element 
      items: [
          {nsn: '2840-01-461-8833NZ', part_name: 'adfasdfasdf', id:'562'},
          {nsn: '1111-22-333-4444', part_name: 'afafdsdf', id:'902'},
      ],
      options: [
          {nsn: 'NA', part_name: 'F100 Variable Vane', id:'329'},
  {nsn: 'N/A', part_name: 'F100 Variable Vane', id:'331'},
  {nsn: '6685-01-281-6849AW', part_name: 'Generator Oil Temperature   Indicator', id:'672'},
  {nsn: '6680-01-350-8049RK', part_name: 'Fuel Quantity Indicator', id:'391'},
  {nsn: '6680-01-350-8048RK', part_name: 'Indicator, Liquid Quantity', id:'367'},
  {nsn: '6680-01-224-7271RK', part_name: 'Fuel Quantity Indicator', id:'390'},
  {nsn: '6680-00-220-4090RK', part_name: 'Fuel Quantity Indicator', id:'389'}
  ],
      render: {
          item: function (item, escape) {
              var name = formatName(item);
              return '&lt;div&gt;' +
              (item.nsn ? '&lt;span class="name"&gt;' + escape(item.nsn) + '&lt;/span&gt;, ' : '') +
              (item.part_name ? '&lt;span class="email"&gt;' +    escape(item.part_name) + '&lt;/span&gt;' : '') +
              '&lt;/div&gt;';
          },
          option: function (item, escape) {
              var name = formatName(item);
              var label = name || item.nsn;
              var caption = name ? item.nsn : null;
              return '&lt;div&gt;' +
              '&lt;span class="label"&gt;' + escape(label) + '&lt;/span&gt;' +
              (caption ? '&lt;span class="caption"&gt;' + escape(caption) + '&lt;/span&gt;' : '') +
              '&lt;/div&gt;';
          }
      },
      create:false
  });
  </code></pre>
  
  <p>So based on the array in items, two items should appear already selected in the multiselect. Everything else works perfectly. Any help is appreciated.</p>