javascriptbatman.js

What is the NamedRouteQuery for 'index' actions in Batman.js


I am trying to redirect to an index action after save, and can't figure out the proper NamedRouteQuery. I have tried:

etc, but in the end the only thing that works is @redirect '/posts'. Is the string version the only option for index actions?


Solution

  • There are a few ways to get this done.

    Passing params to Batman.redirect

    Calling @redirect handles the controller before/afterActions, then delegates to Batman.redirect.Batman.redirect can take:

    * Actually calls record.toParam?() || record.get('id') to get the param

    So, you could use @redirect({controller: "posts", action: "index"}) or @redirect(App.Post) to redirect to the index action.

    Using a NamedRouteQuery

    I'm not great with NamedRouteQuery, but here are some examples anyways:

    You could use one of those to get your url string, then pass the string to @redirect.

    Hope this helps!