jquery.prompt.js - non-blocking popup!

Replaces the script blocking native javascript alerts()'s. Like these culprits: Click alert(), prompt() and confirm() and watch this counter stall =>

Get Started

include this little beaut in your page (along with jquery)

<script src="./jquery.prompt.js"></script>
<link rel="stylesheet" href="./jquery.prompt.css"/>

And then create popups

Methods

This adds the following methods to jQuery

$.fn.confirm([function callback])
Prompt with 'cancel' and 'ok' buttons
$.fn.alert([function callback])
Prompt with 'ok' button
$.fn.prompt([function callback])
Prompt with 'cancel' and 'ok' buttons and input field

Function Callback

The first parameter returns either, bool ('ok' = true, 'cancel' = false) or if a text value is given by the user in the prompt this value is returned.

The scope of the callback is within the DOM form (which belongs to the prompt window). This is so we can access any customised extras which were added to the popup

Dont remind me again

Passing in a boolean value as the second parameter indicates the default value, and an additional "Do not bug me again message". $.fn.prompt(function, true).

refresh

Dont close dialog - e.preventDefault()

There are circumstances like asking user to install a plugin and reload their page, or verifying the value they have provided before closing the dialog. So using preventDefault() lets us persist the dialog.

Styling

Get creative with CSS and you can make some pretty cool looking prompts