Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programatically open a dialog in jquery mobile alpha 4?

I inject html for dialog via script like:

 $("#misc-cntr").append('<div id="chk" data-rel="dialog" > </div>');

then in ajax success callback I have:

success: function(msg) {
$('#chk').html(msg)
 // open dialog here
//  $('#chk').dialog('open')  does not work
}

Given above how can I open the dialog programatically?

like image 453
ace Avatar asked Jun 06 '11 23:06

ace


1 Answers

You'll need to change the page to it, something along the lines of:

$.mobile.changePage($('#chk'), 'pop', false, true);

If you want to close the dialog via javascript, you'll need:

$('#chk').dialog('close');

Hope this helps.

like image 114
J.T.Sage Avatar answered Nov 25 '22 10:11

J.T.Sage