Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember JS how to set up Application

I am an Ember noob and am trying to get it to work; however I am confused about the App.initialize() method.

It throws errors (it can't find the object App) if I use the following code:

App = Ember.Application.extend()
App.initialize()

However if I use the following code; it says initialize is being called twice.

App = Ember.Application.create()
App.initialize()

What is the best way to do this?

like image 446
AbdulFattah Popoola Avatar asked Nov 28 '12 07:11

AbdulFattah Popoola


People also ask

How do I deploy Ember app?

To deploy an Ember application simply transfer the output from ember build to a web server. This can be done with standard Unix file transfer tools such as rsync or scp . There are also services that will let you deploy easily.

Is Ember JS still used?

Ember has been an enabler of great productivity for many teams for almost a decade and I'm sure it's going to continue to be that. It's changed and improved a lot since its first release and is now in better shape than ever with its Octane edition.

What is Ember application?

Ember. js is a productive, battle-tested JavaScript framework for building modern web applications. It includes everything you need to build rich UIs that work on any device.


1 Answers

The Application no longer provides the initialize method. Instead you should use Application#deferReadiness and Application#advanceReadiness combined.

Example extracted from Ember's source code:

App = Em.Application.create();
App.deferReadiness();

jQuery.getJSON("/auth-token", function(token) {
  App.token = token;
  App.advanceReadiness();
});

Additionally, check the sample in jsfiddle:

window.App = Em.Application.create();

App.deferReadiness();

window.setTimeout(function() {
  Em.TEMPLATES["application"] = Em.Handlebars.compile('<h1>App</h1> this is a template');
  App.advanceReadiness();
}, 1500);
like image 159
MilkyWayJoe Avatar answered Sep 20 '22 12:09

MilkyWayJoe