我試圖讓用戶搜索集合中的displayNames和emails。Backbone Marionette Collection Filtering
到目前爲止,我的整個複合視圖看起來像下面的代碼。這呈現和記錄我的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