Search code examples
javascriptember.jscoffeescriptember-old-router

Ember.js router, get router from View


I have an ember.js router based application and need to perform some basic logic on an action before transitioning to a different application state. My button's action would look something like

<button {{action doSomethingThenNavigate target="view"}}>Compute the Change</button>

and I would have a doSomethingThenNavigate method on my Ember.View subclass.

My problem is I don't know how to get the router to trigger the change from within the view, I've tried

doSomethingThenNavigate: ->
    console.log "computing something..." 
    App.router.showCat()

where showCat() is a method on my router. This doesn't work.

I have a jsfiddle exemplifying the problem HERE


Solution

  • Here is the working fiddle.

    You should have to use:

    App.router.send('showCat')
    

    instead of:

    App.router.showCat()