Created
August 4, 2012 13:12
-
-
Save basveeling/3257657 to your computer and use it in GitHub Desktop.
event.context is undefined
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app_router.js | |
EmberTest.Router = Ember.Router.extend({ | |
location: 'hash', | |
enableLogging: true, | |
root: Ember.Route.extend({ | |
index: Ember.Route.extend({ | |
route: '/', | |
redirectsTo: 'posts.index' | |
}), | |
posts: Ember.Route.extend({ | |
route: '/posts', | |
// showPost: Ember.Route.transitionTo('posts.show'), | |
eventTransitions: { | |
showPost: 'posts.show' | |
}, | |
index: Ember.Route.extend({ | |
route: '/', | |
showPost: function(router,event){ | |
console.log(router); | |
console.log(event); | |
console.log(event.context); #is undefined | |
router.transitionTo('show'); | |
}, | |
connectOutlets: function(router) { | |
router.get('applicationController').connectOutlet('posts', EmberTest.Post.find()); | |
}, | |
}), | |
show: Ember.Route.extend({ | |
route: '/:post_id', | |
modelClass: EmberTest.Post, | |
connectOutlets: function(router, post) { | |
router.get('applicationController').connectOutlet('post', post); | |
} | |
}), | |
}) | |
}) | |
}); | |
// post.js | |
EmberTest.Post = DS.Model.extend({ | |
title: DS.attr('string'), | |
body: DS.attr('string') | |
}); | |
// posts.handlebar | |
{{#each post in controller}} | |
<h1><a {{action showPost context="post" href=true}}>{{post.title}}</a></h1> | |
<div>{{post.body}}</div> | |
{{/each}} | |
// console log when clicking a showPost action link in /#/posts: (the three console.log outputs from the showPost action) | |
Class | |
jQuery.Event | |
undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment