A modal dialog is not truly modal if you can see and interact with the page that it is overlaying. To complete this we need to create an overlay that will be semi opaque and sit between the Confirmation dialog and the page.
JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box Etc.
That gives us our HTML and CSS. Now for the jQuery.
While there are many libraries out there that provide this, many of them are over-engineered to do more than the simple requirement of displaying a confirmation dialog with an Ok/Cancel button. Another requirement is how to make the dialog work like the Confirm dialog so that a return value can be tested for the user interaction. This article will show how to build a simple popup dialog using a few lines of jQuery.
We have two options for creating the markup for the popup
I. We can simply put it into the document
II. We can create the markup dynamically with jQuery
For this example we are going to go with option 2. To achieve this we need to convert the overlay and popup markup into jQuery calls to create the elements required.
JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box Etc.
That gives us our HTML and CSS. Now for the jQuery.
While there are many libraries out there that provide this, many of them are over-engineered to do more than the simple requirement of displaying a confirmation dialog with an Ok/Cancel button. Another requirement is how to make the dialog work like the Confirm dialog so that a return value can be tested for the user interaction. This article will show how to build a simple popup dialog using a few lines of jQuery.
We have two options for creating the markup for the popup
I. We can simply put it into the document
II. We can create the markup dynamically with jQuery
For this example we are going to go with option 2. To achieve this we need to convert the overlay and popup markup into jQuery calls to create the elements required.