Backbone: how to render persistent views against back button and refresh for all routes

StackOverflow https://stackoverflow.com/questions/21946609

  •  14-10-2022
  •  | 
  •  

Pregunta

For example, I have a background template view rendered with backbone view when user visits the index route. Then every event is handled by backbone and the template does persist thoughout the routes. However, when I use refresh or backbutton in other routes different than index. my template view disappears. Is there a way to have make background template view persist under any routes against refresh and back button

Edit: I use the routes:

'index' : 'render_bg_template'  

to initialize and render the view. So I am looking for a method to have it rendered after refresh in any routes

¿Fue útil?

Solución

you could listen to the router 'route' event that gets triggered every time a route has occurred.

router.on("route", function(){
   //render template here
});

Docs: "route:[name]" (params) — Fired by the router when a specific route is matched.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top