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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

emartin24Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.