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

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

  •  14-10-2022
  •  | 
  •  

Вопрос

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

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top