Skip to content

Instantly share code, notes, and snippets.

@juggy
Created May 14, 2012 18:42
Show Gist options
  • Save juggy/2695612 to your computer and use it in GitHub Desktop.
Save juggy/2695612 to your computer and use it in GitHub Desktop.
Link state with view, controller, model
Ember.ActiveState = Ember.LayoutState.extend
isActive: false
enter: (manager, transition)->
@_super(manager, transition)
@set("isActive", true)
exit: (manager, transition)->
@_super(manager, transition)
@set("isActive", false)
Ember.ResourceState = Ember.ActiveState.extend
enter: (manager, transition)->
@_super(manager, transition)
id = manager.getPath('params.id')
url = @get("url").replace(":id", id)
# load the resources from server
resource = Ember.Ajax.create({url:url}).get()
@setPath("view.content", resource)
# go up the chain to find a controller to set selection
controller = null
parent = this
while !controller && parent
controller = parent.get("controller")
parent = parent.get("parentState")
@setPath("view.controller", controller)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment