drt5813 2015-05-15 00:15
浏览 112

jquery返回按钮到可排序库中的上一个类别

I have a jquery portfolio gallery with 4 categories which are sortable. When you click on a category the portfolio is rearranged on the same page through jquery showing only those project in that category. Upon clicking a specific project the user can then see the project page/details. I want to add a back button on this page so that when a user is viweing a project they can return to category they were at before.

I tired the following which creates the back button but it take me back to the main portfolio page, not the category which I was browsing before.

function goBack() {
window.history.back();
}

This is one of the gallery page just in case: http://goo.gl/JeSNjD

  • 写回答

2条回答 默认 最新

  • dsfs21312 2015-05-15 00:32
    关注

    Not knowing any of your application's code, this is a bit of a shot in the dark but I think I know what you're probably missing.

    Using the history.back() will take you to the last page you visited (a page visit is only recorded if the URL is updated). If you are updating content in your website with jQuery and not loading a new page, your browser's history doesn't record this so back takes you back to the top page still.

    What you will need to do is change your back button code to hide the current project, and redisplay the category page. You cannot use history.back().

    Edit: If you need more data to correctly rebuild the previous page, you can either change the url for the category page (not necessarily simple to implement but perhaps the most robust thing to do), or to store information about what page they came from. If you are using cookies, you could save navigation there, but you could also add a ref value to the query string when you navigate to a project page.

    Category page:

    <a href="/home/projectName?ref=categoryName">Link to project</a>
    

    Project page:

    <a href="/home?category=categoryName">Back button</a>
    

    Then use that information to reopen or resort your categories.

    评论

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line