title: Selectize: Setting Default Value in onInitialize with setValue
body: <p>I have a web application with multiple Selectize objects initialized on the page. I'm trying to have each instance load a default value based on the query string when the page loads, where <code>?&lt;obj.name&gt;=&lt;KeywordID&gt;</code>. All URL parameters have already been serialized are are a dictionary call <code>that.urlParams</code>. </p>
  
  <p>I know there are other ways to <a href="https://stackoverflow.com/questions/21962124/how-to-set-a-value-for-a-selectize-js-input">initializing Selectize with a default value</a> I could try; but, I'm curious why calling <code>setValue</code> inside <code>onInitialize</code> isn't working for me because I'm getting any error messages when I run this code. </p>
  
  <p>I'm bundling all this JavaScript with Browserify, but I don't think that's contributing to this problem.</p>
  
  <p>In terms of debugging, I've tried logging <code>this</code> to the console inside <code>onInititalize</code> and found that <code>setValue</code> is up one level in the Function.prototype property, the <code>options</code> property is full of data from <code>load</code>, the key for those objects inside <code>options</code> corresponds to the KeywordID. But when I log <code>getValue(val)</code> to the console, I get an empty string. Is there a way to make this work or am I ignoring something about Selectize or JavaScript?</p>
  
  <pre><code>module.exports = function() {    
      var that = this;
  
      ...
  
      this.selectize = $(this).container.selectize({
          valueField: 'KeywordID',  // an integer value
          create: false,
          labelField: 'Name',
          searchField: 'Name',
          preload: true,
          allowEmptyOptions: true,
          closeAfterSelect: true,
          maxItems: 1,
          render: {
             option: function(item) {
                  return that.template(item);
              },
          },
          onInitialize: function() {
              var val = parseInt(that.urlParams[that.name], 10);  // e.g. 5
              this.setValue(val);
          },
          load: function(query, callback) {
              $.ajax({
                  url: that.url,
                  type: 'GET',
                  error: callback,
                  success: callback
              })
          }
      });
  
  };
  
  ...
  </code></pre>