title: jQuery TextExt: Tags with custom data objects
body: <p>I'm currently struggling with implementing a jQuery plugin to my site for tags (with custom data objects) with autocomplete. jQuery TextExt can be found here (<a href="http://textextjs.com/" rel="nofollow">http://textextjs.com/</a>). I'm currently struggling with using custom data objects for each tag, which can only be chosen from what autocompletes. Based on this example (<a href="http://textextjs.com/manual/examples/tags-with-custom-data-objects.html" rel="nofollow">http://textextjs.com/manual/examples/tags-with-custom-data-objects.html</a>) I'm trying to figure out how to return both "name" and "id" when a tag is chosen. Does anyone know how to achieve this or point me in the correct direction?</p>
  
  <p>Perhaps the answer is somewhere in this example (<a href="http://textextjs.com/manual/examples/filter-with-suggestions.html" rel="nofollow">http://textextjs.com/manual/examples/filter-with-suggestions.html</a>)? </p>
  
  <p>Here's what I have written, which isn't working (it only returns the name, I've tried adding 'item.id' to the functions but that didn't work for me either):</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  jQuery(document).ready(function( $ ){
      jQuery('#textarea').textext({
          plugins: 'tags',
          items: [
              { name: 'PHP', id: '1' },
              { name: 'Closure', id: '2' },
              { name: 'Java', id: '3' }
          ],
  
          ext: {
              itemManager: {
                  stringToItem: function(str)
                  {
                      return { name: str };
                  },
  
                  itemToString: function(item)
                  {
                      return item.name ;
                  },
  
                  compareItems: function(item1, item2)
                  {
                      return item1.name == item2.name;
                  }
              }
          }
      });
  })
  &lt;/script&gt;
  </code></pre>