사용자가 컬렉션에서 displayNames 및 전자 메일을 검색 할 수있게하려고합니다.백본 Marionette 컬렉션 필터링
지금까지 전체 합성보기는 아래 코드와 같습니다. 이 렌더링 및 내 var 검색을 기록하지만 collection.where 및 새 Backbone.Collection 후 렌더링을 호출하는 방법을 잘 모르겠습니다?
define(["marionette", "text!app/templates/bamboo/employees/collection.html", "app/collections/bamboo/employees",
"app/views/bamboo/employees/item", "jquery"],
function(Marionette, Template, Collection, Row, $) {
"use strict"
return Backbone.Marionette.CompositeView.extend({
template: Template,
itemView: Row,
itemViewContainer: "ul",
collectionEvents: {
'sync': 'hideLoading'
},
events: {
'keyup #filter-input': 'initialize'
},
initialize: function() {
var search = $('#filter-input').val()
if (typeof(search) != "undefined") {
console.log(search)
var filtered = //somehow search collection displayName and email by value search
this.collection = new Backbone.Collection(filtered);
} else {
this.showLoading()
this.collection = new Collection()
return this.collection.fetch()
}
},
showLoading: function() {
this.$el.addClass('loading')
},
hideLoading: function() {
this.$el.removeClass('loading')
}
})
})
에 대한
다음
는 내 질문에 편집. collection.where는 정확하지 않습니다. – azz0r