ember.js - How to refresh templates in Ember when data is added/removed? -
i have simple part of ember application that's supposed draw list of books. issue if user visits list before books loaded server, list empty. after info finishes loading, list still empty.
what methods ember have to refresh view after info loaded? , appropriate place set code? here's code looks like:
route:
app.myroute = ember.route.extend({ model: function() { homecoming app.store.find(app.book); // books server } });
template:
{{#each book in model}} <li {{ bindattr data-book-id="book.id" }}> <span>{{ book.name }}</span> </li> {{/each}}
for record, this:
{{#if model.get('isloaded')}} {{#each book in model}} <li {{ bindattr data-book-id="book.id" }}> <span>{{ book.name }}</span> </li> {{/each}} {{else}} <span>loading books...</span> {{/#if}}
as stated in comment above, {{each}}
helper has {{else}}
you'd add together spinner list, same way you'd individual item. populating list view, shouldn't have manually phone call method framework responsible populating records in modelarray
gave you. if can't populate info when receive json backend api, problem must in store/adapter/serializer or json format. 1 should check sever sending response , how store set (adapter/serializer/etc) in order translate json response ember-data expects valid info app models.
ember.js ember-data
No comments:
Post a Comment