I have a route and a dynamic sub-route. I have defined a queryParams for my sub-route {queryParams: { start: 5 }}. By default the queryParam is set as 5. So my routes will be:
#/folders/1
#/folders/2
#/folders/3
Now dynamically I change the queryParams of a subRoute as {queryParams: { start: 10 }}. Now the current subRoutes will be:
#/folders/1?start=10
#/folders/2
#/folders/3
After changing the queryParams of a subRoute then visiting other subRoute I need to set queryParams of all the subRoute to "10".
#/folders/1?start=10
#/folders/2?start=10
#/folders/3?start=10
How can I change the queryParams of all the routes when its changing.
@Template:
<script type="text/x-handlebars" data-template-name="folders">
<ul>
{{#each item in model}}
<li>{{#link-to 'folder' item.f_id}}{{item.f_name}} {{/link-to}}</li>
{{/each}}
</ul>
<input type="button" value="Set Start Params" {{action "setStartParams"}}>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="folder">
This is folder listing of Folder {{model.id}}
</script>
@JS Code:
App.Router.map(function() {
this.resource('folders', function(){
this.resource('folder', {path: '/:id'});
});
});
App.FoldersRoute = Ember.Route.extend({
model: function() {
return [{'f_name': 'folder1', 'f_id': '1'}, {'f_name': 'folder2', 'f_id': '2'}, {'f_name': 'folder3', 'f_id': '3'}];
},
actions:{
setStartParams: function(){
this.transitionTo({queryParams: {start: '10'}} );
}
}
});
JSBIN Link
Aucun commentaire:
Enregistrer un commentaire