tags:

views:

311

answers:

1

Hi,

I have the following code;

// open the modal when an element with a class 'edit' is clicked
            $('.edit').live('click', function() {`
                $('#mdl_edit').jqm({onHide: f($(this).attr('id')), ajax: 'ajax/edit_modal.aspx?lid=' + $(this).attr('id'), ajaxText: '<img src="img/ajax-loader.gif"' });
                $('#mdl_edit').jqmShow();
                return false;
            });


var f = function load_it(lID) {    load_single_record(lID); };

the thing is, when ever I click on an element with a class "edit" the function load_it runs before even the ajax call to the edit_modal.aspx.. I actually require it to run after the modal box is closed. Also, I need to pass the $(this).attr('id') to the function that needs to be run after the modal is closed.. I am doing it wrong (I know it) but can someone show me the correct way of calling a function, by also passing a variable to it, after the modal is closed?

regards,

kem

+1  A: 

your problem is that f is executed when the JS engine sets the value of onHide. What you actually want is to have onHide set to an anonymous function, defined inline, that calls load_it:

onHide:function(hash){load_it($(this).attr('id'));}

you don't actually need the hash there, since you're not using it, but (as per jqModal's documentation) there might be some interesting stuff there for you.

DDaviesBrackett