Skip to content

Instantly share code, notes, and snippets.

@afomi
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afomi/efaa60cef3d039c09a3d to your computer and use it in GitHub Desktop.
Save afomi/efaa60cef3d039c09a3d to your computer and use it in GitHub Desktop.
Ember.js

Basics

A request comes in. A URL comes in. And the request is handled by router.js.coffee and a /routes/*_route.js.coffee file.

Assumptions

  • The name of my example Ember App is App.
  • I'm using coffee-script, and I'm assuming it gets compiled to javascript.

Router

/app/router.js.coffee

App.Router.map ->
  @resource "jurisdictions", ->
    @route 'new'
  @resource "jurisdiction", path: '/jurisdictions/:id', ->
    @route 'edit'
    

A Route

You'll have one Route for every URL you have for your site. /, /about, /signup, /login, /widget, /widget/:id.

/app/routes/agencies_route.js.coffee

App.AgenciesRoute = Ember.Route.extend
  model: ->
    @store.find('agency')

App.AgenciesNewRoute = Ember.Route.extend
  # setupController: ->
    # @store.createRecord('agency',
    #   name: "Default Name"
    # )
  renderTemplate: ->
    @render into: "application"

Controller.js.coffee

Properties

Model.js.coffee

DS.attr("string")

View.js.coffee

UI Behaviors

Template.hbs

HTML + Handlebars

Components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment