title: Handling objects with Twitter Bootstrap Typeahead
body: <p>I'm using the Bootstrap Typeahead plugin like so:</p>
  
  <pre><code>$('#Organisation').typeahead({
              source: function (query, process) {
                  return $.get(AppURL + 'Organisations/Manage/SearchByName/',
                  {
                      term: query
                  },
                  function (data) {
                      var results = [];
                      var fullResults = [];
                      $.each(data, function (index, item) {
                          results.push(item.label);
                          fullResults.push({
                              id: item.ID,
                              label: item.label
                          });
                      });
  
                      return process(results);
  
  
                  });
              },
              updater: function (selection) {
                  $('#OrganisationID').val(selection);
              }
          });
  </code></pre>
  
  <p>I have two returned arrays, this is because Typeahead ONLY wants a list of strings instead of an object. The second array contains both the label and id.</p>
  
  <p>Once a user selects an item from the list I need to get the ID from this selection and then use it to insert into a hidden field. But the selection will just be the name, as the ID can't be passed through via Typeahead.</p>
  
  <p>Any ideas on how I can solve this?</p>
  
  <p>An example of the two returned arrays:</p>
  
  <p>results: <code>["Organisation 1","Organisation 2"]</code></p>
  
  <p>fullResults: <code>[{"label":"Organisation 1","ID":2},{"label":"Organisation 2","ID":1}]</code></p>