我有一个主干模型,我想用一些选项对其进行初始化:
Payment.Payment = Backbone.Model.extend
initialize: (attributes, options) ->
@user = options.user
这些付款是通过付款集合从服务器获取的
# Collections: Payments
Payment.Payments = Backbone.Collection.extend
model: Payment.Payment
url: 'api/payments'
initialize: (models, options) ->
@user = if options?.user then options.user else app.user
但是,当我尝试从服务器获取一组付款时,我找不到将用户选项传递给每个付款模型的方法:
payments = new Payment.Payments
payments.fetch()
我尝试将用户选项作为参数传递给 fetch 调用,但这不起作用。那么我怎样才能用用户实例化从服务器获取的所有支付模型呢?