ember.js - emberjs star/unstar items just in the memory -
i build basic emberjs app, app lists posts, , every post has star / unstar event.
list starred posts in sidebar, without server side communications. best way that? first idea that: create star action postscontroller, add starred posts array, , list array in template.
the simplest solution can think set attribute star
on post model false
default, can set star
true
when want , render in sidebar post filtered star attribute.
code (coffeescript) :
app.post = ds.model.extend title: ds.attr('string') star: false app.post.reopenclass stared: -> @filter (post) -> post.get('star') true
from can render app.post.stared()
array in sidebar.
Comments
Post a Comment