【发布时间】:2013-12-06 00:32:33
【问题描述】:
我正在使用 Select2.js、KnockoutJs、Durandal 2.0
var ViewModel =
[
{ id: "AL", text: "Alabama" },
{ id: "AK", text: "Alaska" },
{ id: "AZ", text: "Arizona" },
{ id: "AR", text: "Arkansas" },
{ id: "CA", text: "California" },
{ id: "CO", text: "Colorado" }
]
var stateQuery = function (query) {
var states = [];
ko.utils.arrayForEach(states, function (state) {
if (state.text.search(new RegExp(query.term, 'i')) >= 0) {
states.push(state);
}
});
虽然在下拉列表中绑定它工作正常。但是如果我将 text 更改为 Text_Name 我会得到 cannot convert to upperCase strong> 未定义。
var ViewModel =
[
{ id: "AL", Text_Name: "Alabama" },
{ id: "AK", Text_Name: "Alaska" },
{ id: "AZ", Text_Name: "Arizona" },
{ id: "AR", Text_Name: "Arkansas" },
{ id: "CA", Text_Name: "California" },
{ id: "CO", Text_Name: "Colorado" }
]
【问题讨论】:
标签: knockout.js durandal jquery-select2