title: Materialize autocomplete ajax
body: <p>I'm using the <a href="https://www.npmjs.com/package/materialize-autocomplete" rel="noreferrer">materialize autocomplete</a> plugin to create multiple tags input with autocomplete. Plugin works fine, yet only with data passed as an array defined in advance. If data is passed from ajax call, plugin does not show dropdown with options as if there were no results. There are results in fact, they are cached (using cache option) and are shown as dropdown only after re-typing search phrase.</p>
  
  <p>To sum up, autocomplete plugin does not wait for the ajax to complete its request and deliver data and that is why dropdown is not shown at first try.
  Is there any way to get this plugin to show suggestions in dropdown once these are retrieved trough ajax call?</p>
  
  <p>Plugin initialization:</p>
  
  <pre><code>autocomplete = $('#multipleInput').materialize_autocomplete({
          cacheable: true,
          throttling: true,
          multiple: {
              enable: true,
              maxSize : 5
          },
          appender: {
              el: '.ac-users'
          },
          dropdown: {
              el: '#multipleDropdown'
          },
          getData: function (value, callback) {
  
              callback(value,getAjaxDropdowValuesAutocomplete(value));
          }
  });
  </code></pre>
  
  <p>Function to get values from DB:</p>
  
  <pre><code>function getAjaxDropdowValuesAutocomplete(value){
          var returnArray = [],
          dataArray,
          innerObject = {},
          postParamsObj = {"search" : value};
  
          $.ajax({
              type: "POST",
              url: '/search-elements',
              data: postParamsObj,
              success: function( msg ) {
                  dataArray = msg['data'];
  
                  for(var i = 0;i &lt; dataArray.length; i++){
                      innerObject = {};
                      innerObject["id"] = dataArray[i][0];
                      innerObject["text"] = dataArray[i][1] + " " + dataArray[i][2];
                      returnArray.push(innerObject);
                  }
  
                  // returnArray format [{ 'id': '1', 'text': 'Johnny Bravo' }]       
  
              },
              error : function(msg){
              }
          });
  
      return returnArray;
  }
  </code></pre>