Ember.js Cheat Sheet

A Programming › JavaScript cheat sheet in English by [deleted]

Ember.js cheat sheet made from http://embersherpa.com/cheatsheet/

28,632 views 7,842 downloads 25 Sep 2013 History
4.7 avg · 3 ratings

Basics

App.Ro­ute­r.map(fn)
allows you to add routes and resources to your app
App.ad­van­ceR­ead­iness()
call this function when your app is ready to be initia­lized
App.de­fer­Rea­din­ess()
delays initia­liz­ation until advanc­eRe­adiness is called
App.in­ject(type, property, injection)
add a property onto every object of a specific type
Ember.A­rr­ayC­ont­rol­ler.ex­tend( {} )
represents several objects
Ember.C­on­tro­lle­r.e­xtend( {} )
grouping of specific, non object related functi­onality (e.g authen­tic­ation or search)
Ember.O­bj­ect.cr­eate( {} )
create an instance of an object
Ember.O­bj­ect.cr­eat­eWi­thM­ixins(mixins, {} )
create an instance of an object with mixins
Ember.O­bj­ect.de­stroy()
set isDest­roying to true and schedule removal of all bindings and observing for the end of run loop
Ember.O­bj­ect.get(keyName)
return value of property by given name while respecting computed and observed properties
Ember.O­bj­ect.re­ope­nClass( {} )
add methods and properties to a class
Ember.O­bj­ect.set(keyName, value)
set the value of property while respecting computed proper­ties, unknown proper­ties, property observers and chaining
Ember.O­bj­ect­Con­tro­lle­r.e­xtend( {} )
represents a single object
Ember.i­sNone(obj)
Returns true if the passed value is null or undefined.

Ember.A­pp­lic­ati­on.i­ni­tia­lizer

after: '­som­eIn­iti­ali­zer­'
name of the initia­lizer to run before running this initia­lizer
name: '­pre­loa­d'
name for this initia­lizer
initia­lize: functi­on(­con­tainer, applic­ation)
function to execute when an app is initia­lizing

Ember.A­pp­lic­ation

Ember.A­pp­lic­ati­on.c­reate: ( {
creates an instance that will be your app and your app's namespace
LOG_AC­TIV­E_G­ENE­RATION: true
activate logging of automa­tically generated routes and contro­llers
LOG_ST­ACK­TRA­CE_­ON_­DEP­REC­ATION: true
activate logging of deprecated method or property usage
LOG_TR­ANS­ITIONS: true
activate basic logging of successful transi­tions
LOG_TR­ANS­ITI­ONS­_IN­TERNAL: true
activate detailed logging of all routing steps
LOG_VI­EW_­LOO­KUPS: true
activate logging of results of view and template searches by routes
rootEl­ement
DOM element or jQuery­-co­mpa­tible selector string where your app will be rendered
} );

Ember.R­oute

Ember.R­ou­te.e­xtend: (mixins, {
before­Model: functi­on(­tra­nsi­tion)
hook executed before resolving models (use for early redire­ction)
activate: function
hooked called when router enters route the first time
afterM­odel: functi­on(­model, transi­tion)
hooked called after models are resolved (use for late redirect)
deacti­vate: function
hook executes when the router completely exits this route
model: functi­on(­params)
provides data to be used by the controller and the view
render­Tem­plate: functi­on(­con­tro­ller, model)
hook to override default template rendered for this route
serialize: functi­on(­model)
converts model into parameters for the url
setupC­ont­roller: functi­on(­con­tro­ller, model)
function that can be used to configure the controller
actions
object with properties
actions: { willTr­ans­ition: functi­on(­tra­nsi­tion) }
called whenever transition triggered on current route
actions: { error }
} );

Ember.View

Ember.V­ie­w.e­xtend: (mixins, {
attrib­ute­Bin­dings: ['da­taS­ize­', '­hre­f']
array of View's property names used to calculate View's DOM elemen­t's attributes
classN­ame­Bin­dings: ['is­Ava­ila­ble­', '­col­or']
array of View's property names used to calculate View's DOM elemen­t's class attribute
classN­ames: ['co­lor­', '­siz­e']
array or string of View's class attribute
contro­ller: Ember.C­on­tro­lle­r.c­reate( {} )
instance of descen­dants of the Ember.C­on­troller
defaul­tTe­mplate: Ember.H­an­dle­bar­s.c­omp­ile­('...')
compiled Handlebars template used when the view doesn't have the template or templa­teName property specified
eventM­anager: {}
an object with properties named after events that this view handles and values are functions that process these events
layout: Ember.H­an­dle­bar­s.c­omp­ile­('...')
compiled Handlebars template that wraps the view
tagName: '­em'
string HTML tag to be used for View's DOM element
template: Ember.H­an­dle­bar­s.c­omp­ile­('...')
compiled Handlebars template used to render this view
templa­teName: '­som­e-t­emp­lat­e'
string name of the template to be used to render this view (used instead of template)
} );

Ember.O­bject

Ember.O­bj­ect.ex­tend: (mixins, {
init: function()
method called when an instance of this class is created
} );

Badges

Useful Cheat Sheet Great Cheat Sheet Nice Cheat Sheet Good Cheat Sheet Downloaded from Unusual Locations × 1

Comments (1)

padimas 17:05 21 Jan 2015

thanks for your kindness of sharing this sheet (y)

Reply

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.