我使用 tag-it 插件https://github.com/aehlke/tag-it/downloads https://github.com/aehlke/tag-it/downloads。如何禁用添加新标签?
$(document).ready(function () {
$("#Tags").tagit({
singleField: true,
singleFieldNode: $('#mySingleField'),
// onlyAvailableTags : true,
allowNewTags: false,
tagSource: [@Html.Raw(ViewBag.AvailableTags)]
});
});
我尝试使用onlyAvailableTags : true
and allowNewTags: false
选项,但是没有任何效果。
我通过注释发现:
// Autocomplete will create its own tag from a selection and close automatically.
if (!that.tagInput.data('autocomplete-open')) {
that.createTag(that._cleanedInput());
}
And:
// Create a tag when the element loses focus.
// If autocomplete is enabled and suggestion was clicked, don't add it.
if (!that.tagInput.data('autocomplete-open')) {
that.createTag(that._cleanedInput());
}
它删除了此功能。也许不是最干净的方法,但它确实有效。
只需注释掉if(){ }
loops.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)