Created
April 12, 2013 23:09
-
-
Save mutewinter/5375921 to your computer and use it in GitHub Desktop.
Patch for bit.ly/17NgjCe
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
diff --git a/app.js b/app.js | |
index ac1e125..a6a418a 100644 | |
--- a/app.js | |
+++ b/app.js | |
@@ -113,13 +113,12 @@ EmBlog.Router.map(function() { | |
this.route('new'); | |
//routes to /posts/:post_id | |
this.resource('post', {path: '/:post_id/'}, function(){ | |
- this.route('edit', {path: '/edit'}); | |
- //routes to /:post_id/comments | |
- this.route('comments', {path: '/comments'}); | |
- this.route('newComment'); | |
- this.route('comment', {path: '/comments/:comment_id'}); | |
- this.route('editComment', {path: '/comments/:comment_id/edit'}); | |
- | |
+ this.route('edit', {path: '/edit'}); | |
+ //routes to /:post_id/comments | |
+ this.route('comments', {path: '/comments'}); | |
+ this.route('newComment'); | |
+ this.route('comment', {path: '/comments/:comment_id'}); | |
+ this.route('editComment', {path: '/comments/:comment_id/edit'}); | |
}); | |
}); | |
@@ -202,7 +201,6 @@ EmBlog.PostRoute = Ember.Route.extend({ | |
EmBlog.PostCommentsRoute = Ember.Route.extend({ | |
setupController: function(controller, model) { | |
- console.log('test'); | |
comments = this.controllerFor('post').get('comments'); | |
controller.set('content', comments); | |
} | |
@@ -230,16 +228,9 @@ EmBlog.PostCommentRoute = Ember.Route.extend({ | |
}); | |
-EmBlog.EditCommentRoute = Ember.Route.extend({ | |
+EmBlog.PostEditCommentRoute = Ember.Route.extend({ | |
model: function(params) { | |
- console.log('farfig'); | |
- var commentEdit = this.modelFor('post').get('comments'); | |
- return commentEdit.get(params.comment_id); | |
- | |
- //return EmBlog.Comment.find({post: post.get('id'), id: params.comment_id}); | |
- | |
- //var comment = this.modelFor('post').get('comments'); | |
- //return comment.filterProperty('body', params.comment_id); | |
+ return EmBlog.Comment.find(params.comment_id); | |
}, | |
setupcontroller: function( controller, model) { | |
@@ -254,7 +245,7 @@ EmBlog.EditCommentRoute = Ember.Route.extend({ | |
events: { | |
save: function(comment){ | |
comment.one('didUpdate', this, function(){ | |
- controller.set('isEditing', false); | |
+ this.controllerFor('postEditComment').set('isEditing', false); | |
}); | |
comment.get('transaction').commit(); | |
diff --git a/index.html b/index.html | |
index 4fb59aa..b36486d 100644 | |
--- a/index.html | |
+++ b/index.html | |
@@ -49,8 +49,6 @@ | |
<p> {{#linkTo 'posts.index'}} back {{/linkTo}}</p> | |
<p> {{#linkTo 'post.edit' content}} Edit the post {{/linkTo}}</p> | |
<p>{{#linkTo 'post.comments'}} comments{{/linkTo}}</p> | |
- {{render 'post.comments' comments}} | |
- {{controller}} | |
<div> | |
{{outlet}} | |
</div> | |
@@ -81,11 +79,11 @@ | |
<!-- comment template --> | |
<script type="text/x-handlebars" data-template-name="post/comments"> | |
<h1> Yes Comments template</h1> | |
- {{render 'post.comment' body}} | |
<br/> | |
{{#each controller}} | |
{{body}} <br/> | |
+ <p>{{#linkTo "post.editComment" this}} Edit Comment {{/linkTo}}</p> | |
{{/each}} | |
{{outlet}} | |
</script> | |
@@ -95,18 +93,16 @@ | |
<h1> post comment template</h1> | |
{{postComment.body}} <br/> | |
- <p>{{#linkTo "post.editComment" this}} Edit Comment {{/linkTo}}</p> | |
- | |
<p> {{#linkTo "post.newComment"}} Add comment{{/linkTo}}</p> | |
{{outlet}} | |
</script> | |
<script type="text/x-handlebars" data-template-name="post/_commentForm"> | |
- <form {{action save content on='submit'}}> | |
- {{view Ember.TextArea valueBinding="body" placeholder="body"}} | |
- <button type="submit"> save comment </button> | |
- <button {{action 'cancel' content}}> Cancel</button> | |
+ <form {{action save content on='submit'}}> | |
+ {{view Ember.TextArea valueBinding="model.body" placeholder="body"}} | |
+ <button type="submit"> save comment </button> | |
+ <button {{action 'cancel' content}}> Cancel</button> | |
</form> | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment