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

Throw console error when model data not found #3

Open
irvinebroque opened this issue May 26, 2013 · 1 comment
Open

Throw console error when model data not found #3

irvinebroque opened this issue May 26, 2013 · 1 comment

Comments

@irvinebroque
Copy link

Trying to debug the following situation (where I'm probably messing something up) would be easier with more verbose error handling in the console. In the scenario below, I know spellbinder's data-event is working as expected:

Instantiate new model

foo = new Backbone.Model(name: 'test name')

Render view for table, then render row view into table

class App.FooTableView extends Backbone.View
  template: @template('table')
  initialize: -> Spellbinder.initialize(@)

render: ->
  new App.FooRowView(el: '#foo-row').render()

Constructor for row

class App.FooRowView extends Backbone.View
  template: @template('row')
  model: foo
  initialize: ->
    Spellbinder.initialize(@) 

Model.get works! (yay)

<td><span><%= model.get('name') %></span></td>

data-bind="name" renders nothing, no error to help debug

<td><span data-bind="name"></span></td>

It's clear that spellbinder successfully identifies the data-bind in the template, but it's tough to tell why it's unable to find foo.name, especially since model.get('name') works.

@irvinebroque
Copy link
Author

btw - figured out the issue - I was declaring the model attribute in the constructor (since I was just working with dummy data) and in order for spellbinder to work, the model has to be passed when the view is created, i.e.:

render: ->
  new App.RowView(el: '#row', model: foo).render()

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

No branches or pull requests

1 participant