5

I'm working with some code that uses JQuery's $(document).ready functionality to set up a jqGrid instance. It appears that the code is fired even when returning to the page via a back-button click.

In a stripped-down test page, a similar ready function is not called when reached via a back-button click:

<html>
<head>
    <script type="text/javascript" src="/JQuery/jquery-1.4.2.min.js"></script>

    <script type="text/javascript">

    $(document).ready(function(){
        alert('ready');
    })

    </script>
</head>
<body>
    <p>Index View</p>

    <a href="detail.html">Detail</a>
</body>
</html>

Can you give me some hints of where to look for what is causing this difference in behavior?

I found some related information in an answer to this question, but the page with the overactive ready event doesn't have an event handler registered for unload.

Community
  • 1
  • 1
Frank Schmitt
  • 25,648
  • 10
  • 58
  • 70
  • Can you post your "similar ready function"? Or are you also calling `$(document).ready`? (Sorry, I can't make that clear from the question...) – Frédéric Hamidi Oct 11 '10 at 17:56
  • 1
    The following thread has some good discussion in this regard http://stackoverflow.com/questions/158319/cross-browser-onload-event-and-the-back-button – Mahesh Velaga Oct 11 '10 at 17:59
  • When you say "It appears that the code is fired even when returning to the page via a back-button click", are you positive that it's not loading the DOM state from cache? – Cᴏʀʏ Oct 11 '10 at 18:29

0 Answers0