Skip to content

Instantly share code, notes, and snippets.

Created January 8, 2013 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4487403 to your computer and use it in GitHub Desktop.
Save anonymous/4487403 to your computer and use it in GitHub Desktop.
RuntimeUi.Router.map (match)->
match( '/' ).to 'dashboard', (match)->
match( '/' ).to 'dashboard_home'
match( '/w' ).to 'workspaces', (match)->
match( '/:uid').to 'workspace', (match)->
match( '/' ).to 'workspace_home'
match( '/outer' ).to 'outer'
RuntimeUi.DashboardRoute = Ember.Route.extend
enter: ->
console.log 'de'
@controllerFor( 'dashboard' ).fetchDashboard()
renderTemplate: (controller, model)->
console.log 'drt'
@render
outlet: 'main'
controller.set 'currentWorkspace', ''
dmic = @controllerFor( 'dashboardMenuitems' )
dmic.set 'content', controller.workspaces
@render 'dashboardMenuitems',
outlet: 'menu'
into: 'dashboard'
controller: dmic
RuntimeUi.DashboardHomeRoute = Ember.Route.extend
renderTemplate: (controller, model)->
console.log 'dhrt'
dc = @controllerFor( 'dashboard' )
@render 'dashboard'
outlet: 'main'
controller: dc
into: 'application'
dc.set 'currentWorkspace', ''
dmic = @controllerFor( 'dashboardMenuitems' )
dmic.set 'content', dc.workspaces
@render 'dashboardMenuitems',
outlet: 'menu'
into: 'dashboard'
controller: dmic
RuntimeUi.WorkspacesRoute = Ember.Route.extend
model: (a)->
console.log "wsm1.5", a
renderTemplate: (controller, model)->
console.log "wsrt2"
dbc = @controllerFor( 'dashboardBoxes' )
dbc.set 'content', []
@render 'dashboardBoxes',
outlet: 'main'
into: 'dashboard'
controller: dbc
RuntimeUi.WorkspaceRoute = Ember.Route.extend
model: (urlParams)->
dc = @controllerFor( 'dashboard' )
model = dc.getWorkspace urlParams.uid
console.log "wm", urlParams, urlParams.uid, model
dc.setCurrentWorkspace model
model
renderTemplate: (controller, model)->
console.log "w3", model
dc = @controllerFor( 'dashboard' )
dc.setCurrentWorkspace model
RuntimeUi.WorkspaceHomeRoute = Ember.Route.extend
renderTemplate: (controller, model)->
console.log "whrt4", model
model: (urlParams)->
# dc = @controllerFor( 'dashboard' )
# ws = dc.getCurrentWorkspace()
ws = @modelFor('workspace')
console.log 'wshm1', ws, urlParams
ws
So, when this transition is triggerred:
RuntimeUi.OuterController = Ember.Controller.extend
goToWorkspace: (workspace)->
@transitionTo 'workspace_home', workspace
I'm seeing this output:
wshm1 undefined Object
wsm1.5 Object
wsrt2
w3 Class {uid: "workspace.50e9dde0e6c3e6a608000001", app_instances: Class, owner_uid: "user.50e981156762a60000000039", public: true, admin_uids: Array[0]…}
set current workspace workspace.50e9dde0e6c3e6a608000001 dashboard_controller.js:73
whrt4 undefined
So:
- model() of WorkspaceHome is called first, without arguments. Therefore it cannot know current workspace, and returns undefined
- then calls are done from top, as expected: WorkspacesRoute.model() and .renderTemplate()
- then WorkspaceRoute.model() is skipped (interesting), but .renderTemplate() is called with proper model: the one passed to @transitionTo
- that causes current workspace to be set, so now WorkspaceHome.model() can be called. But, it was called before, returned undefined, so now WorkspaceHome.renderTemplate() is called with undefined().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment