Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.js: Where is the "start" button?

Tags:

ember.js

I'm used to thinking about a single-page application startup happening like this: 1. Bootstrap some data into critical models, 2. Instantiate a master controller, and 3. Call it's render() method to kick things off.

How is this accomplished with Ember? Following the (meager, sigh) examples in the documentation, it seems like things sort of kick off on their own when the page loads -- templates are compiled, views render like magic when the page loads. I feel like I am missing something fundamental. It there an example online of a more complex app, say something with tabbed or dynamically loaded views?

Lightbulb, going off it is not.

like image 659
Chris Herring Avatar asked Jan 27 '12 17:01

Chris Herring


People also ask

Do people still use Ember js?

Yes, less people use it -- that's just the truth. Every year, during the "State of the Web" survey or the NPM survey, Ember will come in behind React, Vue and Angular. But that's always been the state of Ember and it will probably be the state of it indefinitely.

How does Ember js work?

Ember uses templates to organize the layout of HTML in an application. Ember templates use the syntax of Handlebars templates. Anything that is valid Handlebars syntax is valid Ember syntax. Here, {{name}} is a property provided by the template's context.

Is Ember js any good?

Ember. js is considered ideal for long-term projects, single-page apps, web apps that have native features, apps that need a Python-like environment, and apps that have a complicated functionality integration.


2 Answers

I've started a blog series about getting up and running with Ember on Rails. Here's Part 1:

http://www.cerebris.com/blog/2012/01/24/beginning-ember-js-on-rails-part-1/

I hope you'll find it useful, even if you're not planning to use Ember with Rails. Most of the interesting details are client-side and thus server-independent. The posts so far cover creating an Ember.Application object, loading data dynamically through a REST interface, and then rendering an Ember view on a page in handlebars. I hope it's enough to get you started.

like image 199
Dan Gebhardt Avatar answered Nov 11 '22 23:11

Dan Gebhardt


When you extend an ember Application object you can provide a ready function which will be called when the application starts. You have to make sure to call this._super() or else it will break your application. Check out my sample sproucore 2.0 application (ember is the new name of sproutcore 2.0).

The way that ember works is that it sets up a run loop which responds to events. Whenever an event fires, the run loop basically calls the necessary handlers and runs any bindings that need to be updated. Since everything typically happens in the run loop you often don't really write any code to update things. Instead you write bindings which are fired when needed.

like image 33
Blacktiger Avatar answered Nov 12 '22 00:11

Blacktiger