Backbone-relational
Backbone-relational copied to clipboard
backbone collection returns only relational model attributes
I have a speciality model class:
class Persons.Models.Speciality extends Backbone.RelationalModel
paramRoot: 'speciality'
relations: [
type: Backbone.HasMany
key: 'services'
relatedModel: 'Persons.Models.Service'
collectionType: 'Persons.Collections.Services'
includeInJSON: false
autoFetch: true
reverseRelation:
key: 'speciality_id',
includeInJSON: 'id'
]
Persons.Models.Speciality.setup()
It has many relations to services
class Persons.Routers.Services extends Backbone.Router
initialize: ->
@specialities = new Persons.Collections.Specialities()
@specialities.fetch({reset: true})
view = new Persons.Views.ServicesNew({collection: @specialities})
A view class
class Persons.Views.ServicesNew extends Backbone.View
template: JST['cpanel/templates/services/new']
events:
"submit #new-service": "save"
constructor: (options) ->
super(options)
console.log @collection
@model = new @collection.model()
console.log @model
@model.bind("change:errors", () =>
this.render()
)
In Console, console.log @model
It only returns services relational atributes not speciality attributes.
Anything Am I doing something wrong here?