2

使用 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"
        });
 });

如何配置使其显示在文本框中?

谢谢,

4

1 回答 1

0

试试看,

 @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/

于 2014-10-02T22:02:50.717 回答