Google Maps and Share This with AJAX

nate
@nate
10 years ago
917 posts
I have a client for which I built a persistent audio player. So basically the player loads when you land on any skin page and then from there with every new link clicked the page is loaded via AJAX. it grabs the "wrapper" div of the new page and replaces the "wrapper" div of the exiting page.

The problem is Google maps and Share this are not working when that page is loaded via ajax.

I thought of inserting html with a few jamroom vars to replace the sections but each of them do quite a bit in the background, so it will not work.

Are there any suggestions?
updated by @nate: 07/23/15 04:43:55AM
michael
@michael
10 years ago
7,791 posts
Pperhaps re-write the URL when the div is loaded so that the address bar shows the page that would exist if the player wasn't doing its thing.

Not sure if share this would take the URL or not, but its an idea.
nate
@nate
10 years ago
917 posts
Yeah, that's already being done. The Google maps and share this don't show anything. They're both smarty functions.

I do a jQuery load by grabbing the wrapper section from the profile page. Should I grab something from the header that may not already be there?
updated by @nate: 06/29/15 12:06:57PM
brian
@brian
10 years ago
10,149 posts
You're going to have to do some tweaks to get maps working via an ajax call:

http://stackoverflow.com/questions/3922764/load-google-maps-v3-dynamically-with-ajax


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
10 years ago
917 posts
I assume I'll need to do the same type of thing for the "share this"?
brian
@brian
10 years ago
10,149 posts
Natedogg265:
I assume I'll need to do the same type of thing for the "share this"?

Yep - most likely. Anything that works via "document ready" is going to need to be changed if you load it via an AJAX call (i.e. any JS that initializes it must be called on the NEW content that has been loaded).


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
10 years ago
917 posts
Yeah I had done a few for other things, but this was a smarty function and that kinda lost me.
brian
@brian
10 years ago
10,149 posts
Natedogg265:
Yeah I had done a few for other things, but this was a smarty function and that kinda lost me.

yeah a smarty function is only going to run on template load (page load), so if you have embedded a smarty function in a template that is rendered via an AJAX call, you'll have to manually run an JS AFTER the ajax call has returned successful.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

Tags