Expand all

jquery.confirmable

Enable inline confirmation for clickable elements.

Author:
  • Bartosz Dziewoński
License:
  • MIT
Source:

Methods

$.fn.confirmable([options]) → {jQuery}static #

Enable inline confirmation for given clickable element (like <a /> or <button />).

An additional inline confirmation step being shown before the default action is carried out on click.

Calling .confirmable( { handler: function () { … } } ) will fire the handler only after the confirmation step.

The element will have the jquery-confirmable-element class added to it when it's clicked for the first time, which has white-space: nowrap; and display: inline-block; defined in CSS. If the computed values for the element are different when you make it confirmable, you might encounter unexpected behavior.

To use this jQuery plugin, load the jquery.confirmable module with mw.loader.

Example

mw.loader.using( 'jquery.confirmable' ).then( () => {
      $( 'button' ).confirmable();
} );

Parameters:

Name Type Attributes Description
options Object optional
Properties:
Name Type Attributes Default Description
events string optional
'click'

Events to hook to.

wrapperCallback function optional

Callback to fire when preparing confirmable interface. Receives the interface jQuery object as the only parameter.

buttonCallback function optional

Callback to fire when preparing confirmable buttons. It is fired separately for the 'Yes' and 'No' button. Receives the button jQuery object as the first parameter and 'yes' or 'no' as the second.

handler function optional

Callback to fire when the action is confirmed (user clicks the 'Yes' button).

delegate string optional

Optional selector used for jQuery event delegation

i18n string optional

Text to use for interface elements.

Properties:
Name Type Attributes Default Description
space string optional
' '

Word separator to place between the three text messages.

confirm string optional
'Are you sure?'

Text to use for the confirmation question.

yes string optional
'Yes'

Text to use for the 'Yes' button.

no string optional
'No'

Text to use for the 'No' button.

yesTitle string optional

Optional title text to use for the 'Yes' button.

noTitle string optional

Optional title text to use for the 'No' button.

Source:

Returns:

Type
jQuery
Enable inline confirmation for given clickable element (like <a /> or <button />).