使用bootstrap tagsinputs插件,我想在加载视图时为文本框赋值。
传递给视图的值格式是"a,b,c"
这适用于
@Html.TextBoxFor(model => model.mylist, new {@class = "form-control"})
但当我添加data_role="tagsinput"时,不起作用
@Html.TextBoxFor(model => model.mylist, new {@class = "form-control", data_role = "tagsinput" })
也尝试过,但没有运气
$(function () {
var elt = $("#mylisttags-input");
elt.tagsinput({
itemText: "@Model.mylist"
});
});
我该如何配置,使其显示在文本框中?
谢谢,
试试吧,
@Html.TextBoxFor(model => model.mylist, new {@class = "form-control", data_role = "tagsinput" })
$("#mylisttags-input").tagsinput('items'); // to show just pass the items key
http://jsfiddle.net/754wob2q/