Try this:
Working jsFiddle Demo
The important things to know are:
One: You need the references in the
to these three: (1) the jQuery library, and (2) the jQueryUI library, and (3) the jQueryUI css
Two: Any div at all can be made into a dialog. The div can have any HTML formatting and elements, including buttons, images, input boxes, etc. The div, with all its formatted elements, will appear as such in the dialog.
Three: Usual practice is to first initialize the dialog, but set autoOpen: false,
, and then later on you can force it to open with a ('#divID').dialog( 'open' )
command.
Four: The dialog will not auto-close when you click the button. You must close it using the ('#divID').dialog( 'close' )
command
Five: There are many settings you can use when initializing the dialog. Among the most useful or intriguing are:
* autoOpen: true/false,
* width: 500, //Note: no 'px'
* position: 'top',
* draggable: false,
* closeOnEscape: false
Six: To re-use a dialog -- that is, to replace its contents and re-open:
$('#dlgDiv').html('New stuff goes here
');
$('#dlgDiv').dialog('open');
Seven: To outright destroy a dialog (allows you to re-create another dlg using .dialog()
:
$('#dlgDiv').dialog('destroy');
Fully working, stand-alone, cut/pastable example:
Additional Reading:
http://salman-w.blogspot.ca/2013/05/jquery-ui-dialog-examples.html
How to customise jquery ui dialog box title color and font size?
https://www.udemy.com/blog/jquery-popup-window/
How do I pass a an element position to jquery UI dialog
http://api.jqueryui.com/dialog/
jQuery UI dialog button text as a variable
extend jquery ui dialog (add more options)