【发布时间】:2014-08-09 08:32:51
【问题描述】:
我需要知道我的路由是否被调用,因为用户点击了浏览器的后退按钮,而不是点击 {{link-to}} 链接到达那里。这样做的原因是因为我有一个可过滤列表,该列表在该路由的关联模板上带有分页。如果用户离开此列表然后单击后退按钮,我的设计师希望过滤器的状态保持完整。但是,如果用户单击链接到达此列表,我的设计师希望重置过滤器和分页。
例子:
1) Users clicks the 'Books' navigation link and arrives at '/books'.
2) User filters the list goes to page 2 of results. This does not update the URL and user is still at '/books'.
3) User clicks one of the Books and goes to '/books/123'.
4) User clicks the browser Back button and goes back to '/books'. I need to show the filtered list at page 2.
5) User clicks the 'About Us' link and goes to '/about'
6) User clicks the 'Books' navigation link and arrives at '/books'. But this time, the user didn't click the browser Back button to arrive here, so I need to reset the filters and show a list of unfiltered Books on page 1.
在第 4 步和第 6 步中,用户到达 '/books' 和 BooksRoute,但他们到达那里的机制不同,所以我需要显示不同的书籍列表结果。有没有办法判断是否调用了 Route 是因为单击了 Back 按钮而不是单击了超链接?
【问题讨论】:
标签: ember.js routes browser-history