title: How to prevent duplicate with Bootstrap Tokenfield When using Jquery Ui Autocomplete
body: <p>I am trying to implement <a href="http://sliptree.github.io/bootstrap-tokenfield/#examples" rel="noreferrer">Bootstrap Tokenfield with Jquery Ui autocomplete</a>
   and so far i was able to do that except the fact that i am not able to prevent duplicates in the input field, so, unfortunately my user can choose the same value twice. </p>
  
  <p>In my search i have found that Bootstrap Tokenfield has a way of <a href="https://github.com/sliptree/bootstrap-tokenfield?files=1" rel="noreferrer">preventing duplicate</a>. However I do not know how to apply to my code because it looks to me that it goes with Twitter typeahead and not Jquery Ui.</p>
  
  <p>How can i prevent duplicate with Bootstrap TokenField Using Jquery Ui autocomplete ?</p>
  
  <p>This is my Bootstrap TokenField code based on jquery ui autocomplete</p>
  
  <pre><code>$('.tokenfield').tokenfield({
    autocomplete: {
      source: [
      {
          "id": "1",
          "value": "Ferdine Faithfull" 
      },
      {
          "id": "2",
          "value": "John Carta" 
      },
      {
          "id": "3",
          "value": "Mezane Smith" 
      }
      ],
  
      delay: 100
    },
    showAutocompleteOnFocus: true
  });
  </code></pre>
  
  <p>And below is what i have found on Github to prevent duplicate though i think it is  for Typeahead</p>
  
  <pre><code>$('#my-tokenfield').on('tokenfield:createtoken', function (event) {
      var existingTokens = $(this).tokenfield('getTokens');
      $.each(existingTokens, function(index, token) {
          if (token.value === event.attrs.value)
              event.preventDefault();
      });
  });
  </code></pre>