title: jquery autocomplete: Get "new" values when they're done
body: <p>I've got a jquery autocomplete text box (multiple: true) used to set categories on an item, pretty much exactly like the stackoverflow tags.</p>
  
  <p>The autocomplete source is a list of objects, with formatItem overriden to do the correct display.</p>
  
  <p>What I'm trying to do is pull two lists out of it: one list of selected category IDs (array of integers), and a list of any "new" categories they've entered that weren't in the original list.  This is what I tried:</p>
  
  <pre><code>var categories = [];
  var newCategoryNames = [];
  
  var collectData = function(event, itemData, formatted) {
      if (itemData == null)
      {
          // no match -- new category
          newCategoryNames[newCategoryNames.length] = formatted;
      }
      else
      {
          categories[categories.length] = itemData.iCategoryID;
      }
  };
  $('#txtCategories').result(collectData).search().unbind('result');
  </code></pre>
  
  <p>This works fine for the pre-existing categories ("else" clause), but fails on the new items ("if" clause).  This is because not only is itemData passed in null in that case, but the formatted parameter is null as well.  I had thought it would still be passed in as the user-entered text but apparently not.</p>
  
  <p>So what can I do?  That callback IS called on the non-matching item, but it doesn't seem to give me any information that will tell me what that non-matching item actually was.</p>