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

Ember authentication best practices?

UPDATE: Like @DustMason says in his answer, check out the awesome embercasts for authentication best-practices. Client Side Authentication Part I Client Side Authentication Part II In order to completely separate the view (Ember app) from the server (Rails app) I want to use token authentication. I will likely use Devise on the Rails server. Makes … Read more

emberjs – how to mark active menu item using router infrastructure

Ember 1.11+: {{#link-to “dashboard” tagName=”li”}} <a href=”https://stackoverflow.com/questions/11628489/{{view.href}}”>Dashboard</a> {{/link-to}} Ember < 1.11 (bind-attr required): {{#link-to “dashboard” tagName=”li”}} <a {{bind-attr href=”https://stackoverflow.com/questions/11628489/view.href”}}>Dashboard</a> {{/link-to}}

infinite scroll with ember.js (lazy loading)

I’ve implemented an infinite scroll mechanism at the GitHub Dashboard project, I’m currently developing. The feature is added in commit 68d1728. The basic idea is to have a LoadMoreView which invokes the loadMore method on the controller every time the view is visible on the current viewport. I’m using the jQuery plugin inview for this. … Read more