PDA

View Full Version : jQuery jqm plugin: use variable for ajax call issue


jjshell
07-30-2009, 03:33 PM
Hi,

Please consider the code below.

If remove the quotes around the url var (otherwise it was passed as a string). If I alert() it the url var when onHide is triggered, the expected url is
displayed in the alret box. If I type the full url, between single quotes, in the ajax parameter of jqm, everything's fine. If I use my url var for the ajax call... it fails.


var url;
$('a.edit').livequery('click',function(){
url = $(this).attr('href');
return false;
});

$('#modal-test').jqm({
ajax: url,
onHide: function(h) {
url= url + 'session/close/';
$.get(url);
h.o.remove(); // remove overlay
h.w.fadeOut(1); // hide window
},
});

$('a.edit').livequery('click',function(){
$('#modal-test').jqmShow();
return false;
});

Can someone tell me how to use the url var with the ajax parameter?

Thanks in advance.

Regards,

-jj. :)

Uzbekjon
08-13-2009, 01:28 PM
Most probably url is undefined!

You should probably combine those two click events into the one:

$('a.edit').livequery('click',function(){
url = $(this).attr('href');
$('#modal-test').jqmShow();
return false;
});