Backbone.js model.get() returning 'undefined' even though I can see the attributes in console.log

前端 未结 3 719
轻奢々
轻奢々 2020-11-29 10:32

I have a model instance, which I set another model instance on, i.e model.set(\'rsvp\', new App.Rsvp).

When I iterate over the collection to generate th

3条回答
  •  感情败类
    2020-11-29 11:16

    In theory what you are doing should work, but it's probably not a good idea to bypass attributes and store properties directly on model instances. Here's a jsfiddle that shows it works in concept. My guess is that your model instance is getting recreated from source data via fetch somewhere else in your code so the model.rsvp property disappears. That or model is not the same instance you think it is.

提交回复
热议问题