How to handle scroll position on hashchange in Backbone.js application?

前端 未结 4 721
悲哀的现实
悲哀的现实 2021-02-01 17:05

I\'ve read through many related threads but none of them seem to provide a solution.

What I\'m trying to do is handle the scrollbar intelligently in my Backbone.js app.

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-01 17:40

    I have a slightly poor-man's fix for this. In my app, I had a similar problem. I solved it by putting the list view and the item view into a container with:

    height: 100%
    

    Then I set both the list view and the item view to have:

    overflow-y: auto
    height: 100%
    

    Then when I click on an item, I hide the list and show the item view. This way when I close the item and go back to the list, I keep my place in the list. It works with the back button once, although obviously it doesn't keep your history, so multiple back button clicks won't get you where you need to be. Still, a solution with no JS, so if it's good enough...

提交回复
热议问题