I'm in the process of hacking/learning my way though backbone.js. For some reason I can follow the @account model instance all the way down to the view but in the template when I do <%= account.get('name') %>
nothing is returned. When I do <%= account %>
I get [object Object]
Am I simply using the wrong tag to display account
?
Anyways, here's my code.
Router: shows.js.coffee:
class AppName.Routers.Shows extends Backbone.Router
routes:
'': 'index'
initialize: ->
# Fetch Show Dates
@collection = new AppName.Collections.Shows
@collection.fetch()
# Fetch Account Info
@account = new AppName.Models.Account
@account.fetch()
index: ->
# Shows
view = new AppName.Views.ShowsIndex(collection: @collection)
$('div.shows_container').html(view.render().el)
# Account
view = new AppName.Views.Account(model: @account)
$('div.account_container').html(view.render().el)
Model: show.js.coffee
class AppName.Models.Account extends Backbone.Model
urlRoot: 'api/account'
View: show.js.cofee
class AppName.Views.Account extends Backbone.View
template: JST['accounts/show']
render: ->
$(@el).html(@template(account: @model))
this
Template: show.jst.ejs
<%= account.get('name') %>