public
Created

Patch for bit.ly/17NgjCe

  • Download Gist
ed.patch
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
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>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.