views:

251

answers:

2

Hi,

What I need is very simple but, searching the web, I didn't find any example.

I am using the jqModal jQuery plugin for displaying content dynamically (via Ajax) in a modal dialog. Once, this modal content is loaded, I need to bind some event on the dialog DOM elements. Therefore, I would like to assign an handler to the "success" AJAX event for manipulating these DOM elements.

The problem is that, looking into the jqModal documentation, there is no 'success' defined events. For instance, the code:

$('#ex2').jqm({ajax: 'examples/2.html', trigger: 'a.ex2trigger'});

will call the examples/2.html for the Ajax request and the response content will replace ex2 content...

...but how can I define my handler for success (or error) such that I can bind some events on the new content of '#ex2' ?

Thank you in advance for your help,

Fabien.

A: 

I'm guessing you're using the jqModel plugin? For success (not sure of error) you can add onLoad(callback) as detailed here

So for instance

$('#ex2').jqm({ajax: 'examples/2.html', trigger: 'a.ex2trigger', onLoad: doStuff});

function doStuff() {
   //Do stuff here
}
Jay
Sorry but I don't get your answer. I am using the jqModal plugin. See http://dev.iceburg.net/jquery/jqModal/ for more details. Concerning your solution, can you provide some code example because I don't see how to use it. Thank you.
fabien7474
Updated with code examples.
Jay
Ok. I've found it in the jqModal docs! Yes I think that this is waht I need. I'll give a try and tell you. Thx
fabien7474
A: 

You can use the onLoad callback, see here: http://dev.iceburg.net/jquery/jqModal/

$('#popup').jqm( { onLoad:onLoadCallback } );
cxfx