Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery UI API - Dialog Widget

jQuery UI API - Dialog Widget

Category

Widgets

Usage

**Description:** Open content in an interactive overlay.

**Version added:** 1.0

A dialog is a floating window with a title bar and a content area. A dialog window can be moved, resized, and by default closed via the 'x' icon.

If the content exceeds the maximum height, a scrollbar appears automatically.

A bottom button bar and a semi-transparent modal overlay are common additions.

Focus

When a dialog is opened, focus automatically moves to the first item that meets the following conditions:

  1. With autofocus The first element within the dialog with an autofocus attribute
  2. The first tabbable element within the dialog content :tabbable Element
  3. The first button within the dialog's button pane :tabbable Element
  4. The dialog's close button
  5. The dialog itself

When opened, the Dialog Widget ensures that focus cycles via Tab among elements inside the dialog, excluding elements outside it. Modal dialogs prevent mouse users from clicking elements outside the dialog.

When the dialog is closed, focus automatically returns to the element that had focus before the dialog was opened.

Hiding the close button

In some cases you may want to hide the close button, for example when there is already a close button in the button pane. The best solution is via CSS. As an example, you can define a simple rule like:



.no-close .ui-dialog-titlebar-close {

  display: none;

}

Then you can add a no-close class to any dialog to hide its close button:



$( "#dialog" ).dialog({

  dialogClass: "no-close",

  buttons: [

    {

      text: "OK",

      click: function() {

        $( this ).dialog( "close" );

      }

    }

  ]

});

Theming

The Dialog Widget uses jQuery UI CSS Framework to define the style of its look and feel. To use dialog-specific styling, you can use the following CSS class names:

- `ui-dialog-titlebar`: The title bar containing the dialog's title and close button. - `ui-dialog-title`: The container around the dialog's text title. - `ui-dialog-titlebar-close`: The dialog's close button. - `ui-dialog-buttonset`: The container around the buttons.

In addition, when the modal option is set, an element with a ui-widget-overlay class name is appended to 。

Depends on

Additional Notes

Example

A simple jQuery UI dialog.









  

  对话框部件(Dialog Widget)演示

  

  

  





 



我是一个对话框