我有代码搜索使用 knockout.js
function UserListModel(list) {
var self = this;
self.searchData = ko.observable();
//self.pagedList = ko.utils.pagedObservableArray(list);
self.pagedList = ko.utils.pagedObservableArray({ data: list, showFirstLast: true });
var allData = list;
self.clearSearch = function () {
self.searchData("");
self.pagedList.allData(allData);
};
self.search = function () {
var filterData = allData;
if (self.searchData() != "") {
filterData = $.grep(allData, function (e) {
return e.Name.search(self.searchData()) >= 0;
});
}
self.pagedList.allData(filterData);
};
}
搜索时只能搜索大写或小写的精确输入文本。我希望它能够搜索相对的大写和小写。