Use simplemodal jQuery function from an AJAX created div.

I have a page with a list of locations. When a location is clicked, an AJAX call is made and a map appears in a div on the page. I want a modal popup to appear when the map is clicked.

I use the jQuery plugin simplemodal on other pages for this functionality, and if I put the map on the original page, it performs as expected. But if I try to use it with the map from the AJAX call, I get nothing.

Is there a way to get simplemodal to work on the results of an AJAX call, or is there a better way to do this?

I don't need help with basic functionality . Everything works if it is on the primary page. It just won't work from the AJAX created map that is on the same page. I have tried this with the CSS and the jQuery in the primary page and in the AJAX inserted code, and can't get it to work.

I'd appreciate your help or ideas on how to make this happen.

LVL 6
birwinAsked:
Who is Participating?
 
emartin24Connect With a Mentor Commented:
Here's an example of how to create a modal after an AJAX request:

$.get(URL, function(data){
	// create a modal dialog with the data
	$(data).modal({
		// options
	});
});

Open in new window

0
 
birwinAuthor Commented:
Hi, Sorry to take so long to get back to you.
Unfortunatley, I am not sure what I need to do with your code. Does this go in the generated code or on the page calling it? What "options" to I include.
I have since found that almost no jQuery code will work in the code rendered by the AJAX call. I also tried a "zoom" plugin for an image in the requested code and I get no functionality. But if the identical code is left on the page that calls the AJAX code, it works as expected.
Is there a method to get these functions to work in the AJAX rendered code?
I even copied the Interpreted Source Code as a test_ajax.php page and called it. Any time that I tried to put interactive code within the div into which the AJAX code is inserted, it would not function, so I assume that jQuery is taking control of the div and affecting code within it, even if it wasn't actually rendered by an AJAX call.
Brian
0
 
birwinAuthor Commented:
The answer was not complete, and I got no response to my questions about it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.