ember.js - How can I use a custom/dynamic attribute for a view in Ember JS? -
ember.js - How can I use a custom/dynamic attribute for a view in Ember JS? -
my handlebars file looks bit this:
{{#each book in view.bookcase}} {{view app.bookview classbinding="book.read:read:unread"}} {{/each}} i'd add together attribute tune of book-id="1" or whatever current book's id is, have no thought how. if seek this...
{{#each book in view.bookcase}} {{view app.bookview book-id="book.id" classbinding="book.read:read:unread"}} {{/each}} ...then attribute literally gets set "book.id". ideas?
hmm, @ first thought using attributebindings allowed according this post , this post, when seek it, error:
uncaught error: assertion failed: setting 'attributebindings' via handlebars not allowed. please subclass ember.view , set there instead. so think best method doing in class instead.
handlebar template:
<script type="text/x-handlebars"> {{#each book in view.bookcase}} {{view app.bookview classbinding="book.read:read:unread" contentbinding="book"}} {{/each}} </script> extended class:
app.bookview = ember.view.extend({ attributebindings: ['book-id'], 'book-id': function() { homecoming this.content.id; }.property('content.id') }); example: jsfiddle snippet
ember.js handlebars.js
Comments
Post a Comment