在 serializeData 中过滤数据
filtering data in serializeData
我将一组集合提供给了我的 CompositeView。
对于每个集合,我都试图显示一个矩形,并在其中显示该集合的前 3 个模型。
由于每个系列可能有超过 3 个模型,我想 trim 将其减少到始终为 3 个或更少。我正在使用小胡子,所以我不能在那里做,所以我想在 childView 或 Show.Item 的 serializeData 中做,但我很困惑,我不理解 serializeData 函数的上下文。当我查看 this
时,它给了我 window 对象。
我应该在哪里进行过滤?
collection 1
collection 1
model 1
model 2
model 3
collection 2
model 1
model 2
model 3
model 4
new Show.Items
collection: collection
class Show.Item extends App.Views.ItemView
template: "templates/_item"
class Show.Items extends App.Views.CompositeView
template: "templates/show"
childView: Show.Item
childViewContainer: '.items'
似乎失去了上下文,解决这个问题的最简单方法是使用下划线绑定所有方法 bindall
我将一组集合提供给了我的 CompositeView。 对于每个集合,我都试图显示一个矩形,并在其中显示该集合的前 3 个模型。
由于每个系列可能有超过 3 个模型,我想 trim 将其减少到始终为 3 个或更少。我正在使用小胡子,所以我不能在那里做,所以我想在 childView 或 Show.Item 的 serializeData 中做,但我很困惑,我不理解 serializeData 函数的上下文。当我查看 this
时,它给了我 window 对象。
我应该在哪里进行过滤?
collection 1
collection 1
model 1
model 2
model 3
collection 2
model 1
model 2
model 3
model 4
new Show.Items
collection: collection
class Show.Item extends App.Views.ItemView
template: "templates/_item"
class Show.Items extends App.Views.CompositeView
template: "templates/show"
childView: Show.Item
childViewContainer: '.items'
似乎失去了上下文,解决这个问题的最简单方法是使用下划线绑定所有方法 bindall