Thanks for your suggestion!  (And sorry for the botched subject line!)
Kynn


On Tue, Oct 7, 2008 at 8:03 AM, Rene Veerman <[EMAIL PROTECTED]> wrote:

>
> add a global variable somewhere that your onready callback checks? if true:
> execute, if false:dont.
> then manipulate that global var instead of the callback itself?
>
>
> Kynn Jones wrote:
>
>> I have a jQuery-based script that performs some updates on the current
>> page (using the load method), and eventually visits a second page, by
>> resetting window.location.
>>
>> This works fine, but if the user hits the back button, the whole sequence
>> is repeated, including the re-loading of the second page.
>>
>> I'd like to prevent this behavior.  Is it possible?
>>
>> I tried removing the script with $( 'script[src*=/path/to/script]'
>> ).remove(), but this did not prevent the whole sequence from running again.
>>
>> Then I thought that the reason for this was that using remove() does not
>> get rid of the callback that was originally installed at the very end of the
>> script with jQuery( MyScript.sleep ).  So I tried to uninstall the callback
>> with $( 'document' ).unbind( 'ready', ... ), but this didn't do anything
>> either.
>>
>> How can uninstall the onready callback?  If this is not possible, is there
>> some other way that I can block the sequence from running a second time when
>> the user the BACK button?
>>
>> The script has the following form:
>>
>> var MyScript = ( function ( $ ) {
>>  var SELF_URL = location.pathname + location.search;
>>
>>  var $$; $$ = {
>>    check: function () {
>>      if ( $$.results_ready() ) {
>>        $( 'script[src*=/path/to/script]' ).remove();
>>        $( 'document' ).unbind( 'ready', $$.sleep );  // is this right???
>>        window.location = SELF_URL + '&results=1';
>>      }
>>      else {
>>        $$.sleep();
>>      }
>>    },
>>
>>    sleep: function () {
>>      setTimeout( $$.refresh, 2000 );
>>    },
>>
>>    refresh: function () {
>>      $( 'body' ).load( SELF_URL, $$.check );
>>    },
>>
>>    results_ready: function () {
>>      // etc., etc.
>>    }
>>  };
>>
>>  return $$;
>> } )( jQuery );
>>
>> jQuery( MyScript.sleep );
>>
>>
>>
>> Thanks in advance!
>>
>> Kynn
>>
>>
>>
>

Reply via email to