Export to GitHub

nyromodal - issue #23

jQuery click events on AJAX content


Posted on Jun 3, 2008 by Happy Elephant

What steps will reproduce the problem? 1. Define a jQuery click event function. 2. Load content into modal with AJAX call. 3. jQuery click events are not called from AJAX loaded nyroModal content.

What is the expected output? What do you see instead?

I would like the "Add Nickname" and "Add Location" calls to work in the modal as they do on the following page.

http://itg.midmich.edu/directory/

Do I have to put this content in an iFrame? I am calling other forms fine, but any javascript functions that are included in the <head> of my page can't be called by an AJAX called nyroModal.

What version of the product are you using? On what operating system? nyroModal 1.2.6 on Mac OS X 10.5.3.

Please provide any additional information below.

Comment #1

Posted on Jun 3, 2008 by Swift Panda

As quick fix, you can simply put your javascript code in the body part of your page and it will work. If you want use an ajax request with a targeting content, put this javascript in the content targetted.

NyroModal doesn't eval the script in the head part of the page loaded by ajax. I did that because of all the javascript included in the head part. I didn't want to reload the jQuery library for example.

Here is how I can fix it: - If it's a targeted content, only the script in the element targeted will be evaluate - If it's not, only the inline script (even in the head part) will be evaluated. All the script with a src attribute will be simply ignored.

What do you think?

Comment #2

Posted on Jun 3, 2008 by Happy Elephant

Adding the scripts to the body of the content worked perfectly! Thanks for the help and for the great plugin.

Comment #3

Posted on Jun 13, 2008 by Swift Panda

toddtreece, I just released the version 1.2.7 which will allow you to let your code in the head part of your page. Be sure to read the usage part of the documentation to understand exactly which scripts will be included.

Status: Fixed

Labels:
Type-Defect Priority-Medium