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

无人久伴 提交于 2019-12-11 21:22:32

问题


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!


回答1:


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!');
    }
});


来源:https://stackoverflow.com/questions/19400421/how-to-run-a-function-when-ember-finished-loading-for-the-first-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!