We have created a basic implementation of a Modal Dialog with Javascript, it uses the the Control.Modal library and takes a small amount of configuration.
new Control.Modal.Dialog(element, options)

Element is a DOM element for Control.Modal to attach to, if it si a link it will grab the contents of the link to display as the dialog.

options is a javascript object which can contain any of Control.Modal’s arguments or 3 of it’s own. These are:

  • onsubmit: callback function which will be called when any form is submitted. If this returns true the Dialog will be dismissed.
  • request: is an object like that used in Ajax.Updater, this object can have 2 callback functions, onSuccess and onFailure these are both executed after the form has been submitted and executed on the result of the following Ajax.Request. If these return true the dialog will be dismissed, or on false it is updated with the result of the request.
  • cancel: is a css selector string which Control.Modal.Dialog will attach to to dismiss the dialog

onsubmit - a function to be executed when the form is submitted. This will be executed with an object containing all name/value pairs within the form as an argument.

cancel - this is a CSS selector of any input or link that will cancel the dialog. Defaults to input[name=Cancel]

Download

Share this Post