Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backbone collection returns only relational model attributes #519

Open
samarthsikotara opened this issue Feb 16, 2015 · 0 comments
Open
Labels

Comments

@samarthsikotara
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants