history.back();不会触发$(document).ready(); [英] history.back(); doesn't trigger $(document).ready();

查看:143
本文介绍了history.back();不会触发$(document).ready();的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 $(document).ready()构建界面的网页。然后用户可以转到子页面,并返回到原始页面,他可以按浏览器的上一个按钮或页面中的返回按钮,触发 history.back() ; 。回到原始页面, $(document).ready()未被触发,因此页面缺少信息。

I have a webpage that use $(document).ready() to build the interface. Then the user can go to a child page, and to go back to the original page he can press the browser's "previous" button or a "Return" button in the page which triggers a history.back();. Back on the original page, $(document).ready() is not triggered so the page is missing informations.

有没有办法自动触发它,就像它是真正的负载一样?

is there a way to trigger it automatically like if it was a "real load"?

谢谢!

编辑

在其中发出警报,警报已启用但我的界面中缺少某些内容,就好像某些部分准备好了事件不见了。调查...

placing an alert in it, the alert is poped but stuff is missing in my interface like if some part of the ready event is missing. Investigating...

编辑2

haha​​hahaha in document.ready I 点击一些应该取消选中的复选框。当我在这个页面上退回时,会检查它们以便取消选中它们,因为我重新点击它们。

hahahahaha in document.ready I click some checkbox which are supposed to be unchecked. When I "back" on this page, they are checked so they become unchecked because I reclick them.

对不起,这完全是我的不好:(

Sorry, this is completely my bad :(

推荐答案

这个问题的快速解决方案,改为使用onpageshow。

A quick solution to this problem, use "onpageshow" instead.

window.onpageshow = function(event) {
    //do something
};

这篇关于history.back();不会触发$(document).ready();的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆