tokeninput jquery plugin - preventDuplicates not working
<p>I am using jquery plugin Tokeninput. I need to prevent user from entering duplicate values, the Js code is as follows:</p>

<pre><code>$(document).ready(function () {
    // Configure Tags
    $('#Tags').tokenInput(tagSource(), 
    {
        prePopulate: selectedTags(),
        theme: "facebook",
        propertyToSearch: "Code",
        preventDuplicates: true
     });

    function tagSource() {
        var data = [];
        @if (Model.SourceTags != null &amp;&amp; Model.SourceTags.Count() &gt; 0) {
            &lt;text&gt;
                data = @(Html.Raw(Model.SourceTags));
            &lt;/text&gt;
        }
        return data;
    }

    function selectedTags() {
        var selectedData = [];
         @if (Model.SelectedTags != null &amp;&amp; Model.SelectedTags.Count() &gt; 0) {
            &lt;text&gt;
                selectedData = @(Html.Raw(Model.SelectedTags));
            &lt;/text&gt;
        }
        return selectedData;
    }
});
</code></pre>

<p>When I select the same item again, the existing item in the Input field is highlighted and nothing is added. </p>

<p>Also, when I select a different item, the first item is highlighted and nothing is added.</p>

<p>Any idea?</p>

<p>Thanks</p>
