title: Obtaining data key/value pair from Materialise CSS autocomplete. How?
body: <p>I was able to change the code below to output what I click to console. As you can see, the sendItem function does that for me.</p>
  
  <p>I am having a hard time accomplishing the following:</p>
  
  <ol>
  <li>User types AP</li>
  <li>autocomplete completes it to Apple</li>
  <li>User clicks on APPLE</li>
  <li><strong>Its corresponding value is sent to console</strong></li>
  </ol>
  
  <p>Basically, materialize has a really awesome function they choose to display pictures with, when it can do a lot more. For example, a whole mySQL search based on:</p>
  
  <ol>
  <li>Load the auto complete data with current pending clients</li>
  <li>Each client is a key/value pair in a json array of clients (array of
  arrays)</li>
  <li>autocomplete searches the keys in the data array and upon user
  click,</li>
  <li>dispatches a ajax mysql search for its corresponding value which in
  this case is a unique client id.</li>
  <li>Finally, we render the results to user.</li>
  </ol>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function sendItem(val) {
      console.log(val);
  }
  
  $(function () {
      $('input.autocomplete').autocomplete({
          data: {
              "Apple": null,
              "Microsoft": null,
              "Google": 'http://placehold.it/250x250'
          },
          onAutocomplete: function(txt) {
            sendItem(txt);
          },
          limit: 20, // The max amount of results that can be shown at once. Default: Infinity.
      });
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css" rel="stylesheet"/&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"&gt;&lt;/script&gt;
  
  
  &lt;div class="row"&gt;
      &lt;div class="col s12"&gt;
          &lt;div class="row"&gt;
              &lt;div class="input-field col s12"&gt;
                  &lt;input type="text" id="autocomplete-input" class="autocomplete"&gt;
                  &lt;label for="autocomplete-input"&gt;Autocomplete&lt;/label&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>