I am trying to create a dialog with Jquery mobile
. I have tried to refer to the accepted answer in this SO question but it didn't work for me.
Here is my code:
<div data-role="page" id="first">
<!-- Code -->
<div id = "dialog" data-rel="dialog">
<div id = "errorText"></div>
<button id = "closeDialog">OK</button>
</div>
</div>
And here is the JS to make it (inside a function):
//Nothing checked. Cannot continue. Add error message to div
$('#errorText').html("You must check the checkbox next to \"I Agree\" to continue");
//Open Dialog
$('#dialog').dialog();
When the code to create the dialog is reached nothing happens. Suggestions?
The dialog should be a separate page div which you can load via Ajax or include in your HTML. Here is an example.
Just this,
This worked for me, from the "Local, internal linked "pages"" section of http://jquerymobile.com/demos/1.0b1/#/demos/1.0b1/docs/pages/docs-pages.html
http://jsfiddle.net/homer2/ra7Hv/
I did a generic dialog which opens from JavaScript. I hope this will help you.
HTML
code:And
JavaScript
code:You could use
More info on http://jquerymobile.com/demos/1.0b1pre/#/demos/1.0b1pre/docs/pages/docs-navmodel.html