1
knockout.js 개념 증명을위한 라이브 검색 기능을 연구 중입니다. ko.computed 배열은 내가 믿어야 할 때 아무 것도 반환하지 않습니다. 어떤 도움이라도 대단히 감사하겠습니다. jsFiddleKnockout.JS 관측 가능한 라이브 검색
self = this;
self.query = ko.observable('benefits');
self.samplesharepoint = [
{ title: "benefits", url: "www.benefits.com", sites: "branchburg, branford", topics: "benefits", tagged: "false" },
{ title: "health", url: "www.health.com", sites: "indy, laval", topics: "health", tagged: "false"},
{ title: "benefits", url: "www.benefits.com", sites: "ponce, genentech", topics: "benefits", tagged: "false"}
];
debugger;
self.pageLinks = ko.observableArray(self.samplesharepoint);
self.computedPageLinks = ko.computed(function() {
return ko.utils.arrayFilter(self.pageLinks, function(item) {
return item.title.toLowerCase().indexOf(self.query.toLowerCase()) >= 0;
});
});
감사합니다. 그것은 빠르고 감사했습니다. 조용히 실패하는 이유가 있습니까? 어디서나 오류를 찾을 수 없습니다. – rhythmedium
'ko.observableArray'는 공식 인자가없는 함수이고 모든 함수가 공식 인수의 수인'length' 속성을 가지고 있기 때문에 자동으로 실패합니다 -'ko.utils.arrayFilter'는' self.pageLinks'는'length = 0'을 가진 배열이므로 반복을 시작하지 않습니다 ... – nemesv