# My transitionToRoute method can't trigger the model hook in my route, why?

**URL:** <https://discuss.emberjs.com/t/my-transitiontoroute-method-cant-trigger-the-model-hook-in-my-route-why/5847>\
**Category:** Uncategorized\
**Created:** [July 8, 2014, 2:23am UTC](https://discuss.emberjs.com/t/my-transitiontoroute-method-cant-trigger-the-model-hook-in-my-route-why/5847 "2014-07-08T02:23:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hwoarangzk](https://avatars.discourse-cdn.com/v4/letter/h/919ad9/32.png) [@hwoarangzk](https://discuss.emberjs.com/u/hwoarangzk)\
**Post date:** [July 8, 2014, 2:23am UTC](https://discuss.emberjs.com/t/my-transitiontoroute-method-cant-trigger-the-model-hook-in-my-route-why/5847/1 "2014-07-08T02:23:20Z")

</div>

In my router, I defined one route:

```
this.route('static', {path: '/static/:title'});

```

And in my IndexView’s didInsertElement, when I clicked a button, the following code will be executed:

```
this.get('controller').transitionToRoute('static', {title: 'content'});

```

And in my StaticRoute:

```
App.StaticRoute = Em.Route.extend({

    model: function(param) {
        console.log(_Const.url.getStaticPic + '?callback=?&title=' + param.title);
        return $.getJSON(_Const.url.getStaticPic + '?callback=?&title=' + param.title).then(function(data) {
            return data;
        });
    },

    setupController: (controller, model) {
        console.log('in static setupController');
    }
});

```

When transitionToRoute in the IndexView is called, no info was printed in the console, meaning that the model hook or the setupController hook didn’t get executed in the StaticRoute. Why does this happen? Is there anything I’ve done wrong? Thanks for your help

---

<div class="post-metadata">

**Author:** ![opsb](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/opsb/32/9475_2.png) [@opsb](https://discuss.emberjs.com/u/opsb)\
**Post date:** [July 8, 2014, 7:29am UTC](https://discuss.emberjs.com/t/my-transitiontoroute-method-cant-trigger-the-model-hook-in-my-route-why/5847/2 "2014-07-08T07:29:00Z")

</div>

You pass the model into transitionToRoute so there’s no need to call the model hook. [Controller - 4.4 - Ember API Documentation](http://emberjs.com/api/classes/Ember.Controller.html#method_transitionToRoute)

In your case you should change

```
this.get('controller').transitionToRoute('static', {title: 'content'});

```

to

```
this.get('controller').transitionToRoute('static', model);

```

---

<div class="post-metadata">

**Author:** ![opsb](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/opsb/32/9475_2.png) [@opsb](https://discuss.emberjs.com/u/opsb)\
**Post date:** [July 8, 2014, 7:34am UTC](https://discuss.emberjs.com/t/my-transitiontoroute-method-cant-trigger-the-model-hook-in-my-route-why/5847/3 "2014-07-08T07:34:41Z")

</div>

It seems you can also do what you want more directly using [transitionTo](http://emberjs.com/api/classes/Ember.Route.html#method_transitionTo). This will let you do

```
transitionTo("/static/" + title);

```

it’s available in routes, not sure about controllers. If it’s not available in controllers you can always handle your action in the route instead of the controller and do the transition from there.

---

<div class="post-metadata">

**Author:** ![hwoarangzk](https://avatars.discourse-cdn.com/v4/letter/h/919ad9/32.png) [@hwoarangzk](https://discuss.emberjs.com/u/hwoarangzk)\
**Post date:** [July 8, 2014, 7:49am UTC](https://discuss.emberjs.com/t/my-transitiontoroute-method-cant-trigger-the-model-hook-in-my-route-why/5847/4 "2014-07-08T07:49:08Z")

</div>

```
Thanks! I'll try the 2nd way you told me, I just want to trigger the model hook in the route

```
