jquery プラグイン Tokeninput を使用しています。ユーザーが重複した値を入力できないようにする必要があります。Js コードは次のとおりです。
$(document).ready(function () {
// Configure Tags
$('#Tags').tokenInput(tagSource(),
{
prePopulate: selectedTags(),
theme: "facebook",
propertyToSearch: "Code",
preventDuplicates: true
});
function tagSource() {
var data = [];
@if (Model.SourceTags != null && Model.SourceTags.Count() > 0) {
<text>
data = @(Html.Raw(Model.SourceTags));
</text>
}
return data;
}
function selectedTags() {
var selectedData = [];
@if (Model.SelectedTags != null && Model.SelectedTags.Count() > 0) {
<text>
selectedData = @(Html.Raw(Model.SelectedTags));
</text>
}
return selectedData;
}
});
同じアイテムをもう一度選択すると、入力フィールドの既存のアイテムが強調表示され、何も追加されません。
また、別のアイテムを選択すると、最初のアイテムが強調表示され、何も追加されません。
何か案が?
ありがとう