How to open a jQuery Mobile Dialog from javascript? How to open a jQuery Mobile Dialog from javascript? ajax ajax

How to open a jQuery Mobile Dialog from javascript?


I think that this one is much more elegant:

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

you should have in your html data-role="dialog" instead of page

<div data-role="dialog" id="dialog">...</div>


Add <a> tag anywhere in your page, just put your dialog's id as href as shown below: <a id='lnkDialog' href="#dialog" data-rel="dialog" data-transition="pop" style='display:none;'></a>

And replace $("#dialog").dialog(); inside your success event with $("#lnkDialog").click();


This answer also works:

    $.mobile.changePage('#myPage', {transition: 'pop', role: 'dialog'});