Caching remote data in Local Storage with EmberData

Just to “bump” this thread up a little, because it was one of the top results when I researched solutions for ember local cache of restful api, etc.: Dan Gebhardt seems to do a bloody good job with Orbit.js and its integration into Ember: https://github.com/orbitjs/ember-orbit Orbit is a standalone library for coordinating access to data … Read more

How should errors be handled when using the Ember.js Data RESTAdapter?

This weekend I was trying to figure the same thing out. Going off what Luke said, I took a closer look at the ember-data source for the latest commit (Dec 11). TLDR; to handle ember-data update/create errors, simply define becameError() and becameInvalid(errors) on your DS.Model instance. The cascade triggered by the RESTadapter’s AJAX error callback … Read more

Using Ember.js, how do I run some JS after a view is rendered?

You need to override didInsertElement as it’s “Called when the element of the view has been inserted into the DOM. Override this function to do any set up that requires an element in the document body.” Inside the didInsertElement callback, you can use this.$() to get a jQuery object for the view’s element. Reference: https://github.com/emberjs/ember.js/blob/master/packages/ember-views/lib/views/view.js

Ember.js multiple, named outlet usage

With the new Router you can do something like this: {{outlet “menu”}} {{outlet}} In your Route you can handle the content of the outlets: // application route Ember.Route.extend({ renderTemplate: function() { // Render default outlet this.render(); // render extra outlets this.render(“menu”, { outlet: “menu”, into: “application” // important when using at root level }); } … Read more

How to handle ‘no route matched’ in Ember.js and show 404 page?

App.Router.map(function() { //set up all of your known routes, and then… this.route(“fourOhFour”, { path: “*path”}); }); .. where you have your FourOhFourRoute defined to show the “no route found” message of your choosing. You will be able to access the originally requested path in the fourOhFour route as the path parameter. EDIT: just for clarity … Read more