Search code examples
javascriptember.jsnode-webkit

How to run a function when Ember finished loading for the first time


Hi i'm writing a simple ember app that I run within a node-webkit app, now I would like to run:

require("nw.gui").Window.get().show();

right after Ember finished loading and had rendered the index view, but just once, not if you've just navigated to /.

I've tried this:

App.IndexRoute = Ember.Route.extend({
  setupController: function(controller) {
    require("nw.gui").Window.get().show();
  }
});

But this executes on each navigation to /

Thanks!


Solution

  • Ember.Application has a ready event. That could match your needs.

    You can use it like this:

    window.App = Ember.Application.create({
        ready: function () {
            alert('Application ready!');
        }
    });