# Correct way to transitionToRoute

**URL:** https://discuss.emberjs.com/t/correct-way-to-transitiontoroute/2459
**Category:** Uncategorized
**Created:** [September 5, 2013, 3:28pm UTC](https://discuss.emberjs.com/t/correct-way-to-transitiontoroute/2459 "2013-09-05T15:28:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![axelhzf](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/axelhzf/32/15065_2.png) [@axelhzf](https://discuss.emberjs.com/u/axelhzf)
#### Post date: [September 5, 2013, 3:28pm UTC](https://discuss.emberjs.com/t/correct-way-to-transitiontoroute/2459/1 "2013-09-05T15:28:54Z")

</div>

I’m making a live search on ember.js. This is the code

```
App = Ember.Application.create({});

App.Router.map(function () {
    this.resource("index", {path : "/"});
    this.resource("index", {path : "/:query"});
});

App.Torrents = {
    findByQuery : function (query) {
        var torrents = [];
        if (query) {
            for (var i = 0; i < 5; i++) {
                torrents.push({title : query + i});
            }
        }
        return torrents;
    }
};

App.IndexRoute = Ember.Route.extend({
    model : function (params) {
        return App.Torrents.findByQuery(params.query);
    }
});

App.IndexController = Ember.ArrayController.extend({
    onChangeQuery : function () {
        var query = this.get("query");
        this.transitionToRoute("index", {query : query});
    }.observes("query")
});

```

I have a query property binded to an input. When the input change I want to transition to the route passing the new query parameter, but the IndexRoute.model method is not being called.

Here is the example [http://jsbin.com/ekaGipO/2/edit?html,js,output](http://jsbin.com/ekaGipO/2/edit?html,js,output)

---

<div class="post-metadata">

### Author: ![axelhzf](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/axelhzf/32/15065_2.png) [@axelhzf](https://discuss.emberjs.com/u/axelhzf)
#### Post date: [September 5, 2013, 8:11pm UTC](https://discuss.emberjs.com/t/correct-way-to-transitiontoroute/2459/2 "2013-09-05T20:11:46Z")

</div>

I have the answer in stackoverflow

> <https://stackoverflow.com/questions/18624601/correct-way-to-transitiontoroute/18642910#18642910>
