Skip to content

Instantly share code, notes, and snippets.

@basveeling
Created August 4, 2012 13:12
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 basveeling/3257657 to your computer and use it in GitHub Desktop.
Save basveeling/3257657 to your computer and use it in GitHub Desktop.
event.context is undefined
// 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