I`m a begginer too, and agree this case very much, but I like ember more and more. I think that ember.js has no better guides, the community should improve these, how to use the nested recourses, how to resolve the flow in the controller, router or view, etc.
For example: https://github.com/mharris717/ember-cli-pagination/issues/108
This question is:
I add pagination to my comments of a blog, when I transate from one blog to another, the queryParams(?page=2) and the pagedNumber are still of the one.
1、How to clear the existed variables?
Becouse the ember-cli-pagination access the variables in the controller, I use the willDestroy
in the comments controller, but it has no effect. The doc of the emberjs.com says willDestroy called when App.reset(). I use the init()
, it throw a null error, The code:
willDestroy: function () {
this.set('pagedContent.totalPages', null);
this.set('totalPages', null);
}
The init() code: https://github.com/onecoinim/website.onecoin.im/blob/master/app/controllers/comments.js#L27
So I have to try another method like willDestroyElement
of the View or the deactive
of the route…
In this question, I don’t know (1) I should clear which variable, (2) where and how to clear it.
2、How to access the nested resources.
This is a very easy model: blog has many comments. I have set the routes is
this.resource('blogs',function() {
this.route('show', {path: '/:blog_id'}, function () {
this.resource('comments', function () {
this.route('new');
//this.route('show', {path: ':blog_id'});
//this.route('edit', {path: ':blog_id/edit'});
});
});
});
now it works, the demo is http://onecoin.im/blogs/2/comments
But I have a question:
If i use the url http://onecoin.im/blogs/2 to get the same content of http://onecoin.im/blogs/2/comments , like the ruby on rails, How to do?
The demo: http://onecoin.im/blogs/2/comments
The code: https://github.com/onecoinim/website.onecoin.im
help me, thanks.
MoJie