JQuery Modal Reusable Dialog?
I have been using jquery to enable and disable for the past 6 months.
I have a form where I want to replace 20 different javascript warnings (""); using jQuery Modal dialog boxes.
I don't want to create a separate div div for every other post.
Is there a way with basic jquery-ui to create a reusable modal dialog where I can pass the post title and post body?
Let me know if you have any ideas?
Derek
a source to share
There are many plugins you can find for jQuery for dialog boxes.
I've used the facebox plugin in the past.
Basic usage can be simple:
jQuery.facebox('something cool')
a source to share
Yes, you can create a reusable dialog and you can pass the message dynamically.
-
Create dialog class
function OkDialog() { this.showMessage = function(message) { var $dialog = $('<div></div>') .html(message) .dialog({ modal: true, closeOnEscape: true, buttons: { Ok: function() { $(this).dialog("close"); } } }); $dialog.dialog("open"); } }
-
Create a global object in one of the shared files (jsp).
OK_DIALOG = new OkDialog();
-
Call this function with the desired message.
OK_DIALOG.showMessage("You don't have more than a single penny.");
Work is done!
a source to share
I would recommend the jQuery Growl plugin. http://plugins.jquery.com/project/Growl
The advantage of using Growl is that it has some really good built-in features, in particular the added ability to have an auto-delete feature.
It is not modal-modal.
What I mean is that the user is not required to interact with it before they can return to interacting with the site, thus maintaining the website's workflow.
a source to share
I've used Facebox quite a bit before, but I'm ditching it in favor of a dialog that is part of the jQuery UI collection:
http://docs.jquery.com/UI/Dialog
You mentioned core jquery-ui, doesn't that do the trick?
a source to share