AJAX reload with browser back button and jQuery scripts

1,082 views
Skip to first unread message

garika

unread,
Nov 8, 2012, 1:16:12 PM11/8/12
to resour...@googlegroups.com
Dear All,

I have an issue with my jQuery scripts since AJAX massively appeared in resourcespace.

For example if I click RECENT, my jQuery scripts work well, they are encapsulated in: jQuery(document).ready(function() {
Then I click UPLOAD, then I click the BACK button on my browser, the page is back to its previous state in RECENT, without reload. It is pretty fast compared to before, but my jQuery scripts to not work any more, only if I reload the page or click RECENT again. I presume there is no DOM ready or something. Can you please give me a clue how to proceed, what event to look for?

Thank you!
Cheers
Gergely

Tom Gleason

unread,
Nov 8, 2012, 1:26:05 PM11/8/12
to ResourceSpace
You won't be able to rely on jQuery(document).ready or .load anymore.
Try instead running your scripts without that encapsulation after the relevant elements. (If you're hooking your scripts into the header, you may have to move them to the footer). 

We haven't worked out the exact instructions yet for migrating to ResourceSpace version 5, so let me know how you end up fixing this.




--
 
 



--
Tom Gleason
Buildadam - ResourceSpace Hosting & Development

Colorhythm LLC
http://www.colorhythm.com

Main Office:  +1 415-399-9921
Fax: +1 253-399-9928
Mobile:  +1 347-537-8465

tgle...@colorhythm.com

garika

unread,
Nov 9, 2012, 5:27:23 AM11/9/12
to resour...@googlegroups.com, tgle...@colorhythm.com
Wouldn't it be a solution to trigger some event with jQuery after an AJAX pageload? Can't you just trigger a document.ready once its done? This way most of the scripts would still work well.
(I tried to run my scripts after the relevant elements, but no success yet, I will check deeper).

Cheers
Gergely

Aaron Maturen

unread,
Nov 9, 2012, 6:31:36 AM11/9/12
to resour...@googlegroups.com
You can't just trigger document.ready if your script ties to an element that wasn't in the DOM initially, you're script would have to bind to an element that is there initially and then catch whatever event as it bubbles up...
https://developer.mozilla.org/en-US/docs/DOM_Client_Object_Cross-Reference/DOM_Events
-Aaron
--
 
 

garika

unread,
Nov 9, 2012, 1:22:27 PM11/9/12
to resour...@googlegroups.com
Aaron, I am trying to play with your inline_keywords plugin, which does not select resources after AJAX came into the picture. Do you already have a solution for this issue? You are more deep into jQuery, I'm just an apprentice.

Thank you!

Cheers
Gergely
Reply all
Reply to author
Forward
0 new messages