【发布时间】:2015-02-12 17:12:27
【问题描述】:
<select data-bind="select2: {}"></select>
<input data-bind="select2: {}">
如果我使用带有 select2 的 HTML INPUT 和 foreach 与 asp.net mvc 绑定中的敲除,我会在 internet exploler 中收到此错误
Unhandled exception at line 2890, column 21 in http://localhost:4052/Scripts/knockout-3.2.0.debug.js
0x800a139e - JavaScript runtime error: query function not defined for Select2 undefined
我在 mozilla 和 chrome 中没有遇到任何错误,但是当我这样做时它们的行为也没有达到预期
<input data-bind="select2: {allowClear: true,placeholder: ' write tags here...', multiple: true, tokenSeparators: [',']}">
当我使用<select data-bind="select2: {}"></select> 时,即使在 IE 中我也没有收到任何错误...
基本上,我想在淘汰赛自动生成的表格中有一个标签输入,可以像这样进行标记......
$("#tags1,#tags2").select2({
allowClear: true,
placeholder: "Write Tags Here...",
//createSearchChoice:function(term, data) {return {id:term, text:term};},
//createSearchChoice:function(term, data) { if ($(data).filter(function() { return this.text.localeCompare(term)===0; }).length===0) {return {id:term, text:term};} },
multiple: true,
tags: [],
tokenSeparators: [","]
//maximumInputLength: 15,
//maximumSelectionSize: 5
//data: [{id: 0, text: 'story', locked: true},{id: 1, text: 'bug'},{id: 2, text: 'task'}]
});
我已经使用了这个自定义绑定... https://github.com/select2/select2/wiki/Knockout.js-Integration
【问题讨论】:
标签: jquery html asp.net-mvc knockout.js jquery-select2