behaviors

Drupal. behaviors

Source:
Holds all initialization methods.

Members

Source:
Append is-active class. The link is only active if its path corresponds to the current path, the language of the linked path is equal to the current language, and if the query parameters of the link equal those of the current request, since the same request with different query parameters may yield a different page (e.g. pagers, exposed View filters). Does not discriminate based on element type, so allows you to set the is-active class on any element: a, li…
Type:

(static) AJAX :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Initialize all Drupal.Ajax objects declared in `drupalSettings.ajax` or initialize Drupal.Ajax objects from DOM elements having the `use-ajax-submit` or `use-ajax` css class.
detach Drupal~behaviorDetach During `unload` remove all Drupal.Ajax objects related to the removed content.
Attaches the Ajax behavior to each Ajax form element.
Type:

(static) autocomplete :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches the autocomplete behaviors.
detach Drupal~behaviorDetach Detaches the autocomplete behaviors.
Attaches the autocomplete behavior to all required fields.
Type:

(static) batch :Drupal~behavior

Source:
Attaches the batch behavior to progress bars.
Type:

(static) detailsAria :Drupal~behavior

Source:
Handles `aria-expanded` and `aria-pressed` attributes on details elements.
Type:

(static) detailsSummary :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches behavior for the details element.
Adds a summary of a details element's contents to its summary element.
Type:

(static) drupalAnnounce :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches the behavior for drupalAnnounce.
Builds a div element with the aria-live attribute and add it to the DOM.
Type:

(static) drupalDisplace :Drupal~behavior

Source:
Registers a resize handler on the window.
Type:

(static) entityContentDetailsSummaries :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches summary behavior entity form tabs. Specifically, it updates summaries to the revision information and the translation options.
Sets summaries about revision and translation of entities.
Type:

(static) fillUserInfoFromBrowser :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches the behavior for filling user info from browser.
Prepopulate form fields with information from the visitor browser.
Type:

(static) formSingleSubmit :Drupal~behavior

Source:
Prevents consecutive form submissions of identical form values. Repetitive form submissions that would submit the identical form values are prevented, unless the form values are different to the previously submitted values. This is a simplified re-implementation of a user-agent behavior that should be natively supported by major web browsers, but at this time, only Firefox has a built-in protection. A form value-based approach ensures that the constraint is triggered for consecutive, identical form submissions only. Compared to that, a form button-based approach would (1) rely on [visible] buttons to exist where technically not required and (2) require more complex state management if there are multiple buttons in a form. This implementation is based on form-level submit events only and relies on jQuery's serialize() method to determine submitted form values. As such, the following limitations exist: - Event handlers on form buttons that preventDefault() do not receive a double-submit protection. That is deemed to be fine, since such button events typically trigger reversible client-side or server-side operations that are local to the context of a form only. - Changed values in advanced form controls, such as file inputs, are not part of the form values being compared between consecutive form submits (due to limitations of jQuery.serialize()). That is deemed to be acceptable, because if the user forgot to attach a file, then the size of HTTP payload will most likely be small enough to be fully passed to the server endpoint within (milli)seconds. If a user mistakenly attached a wrong file and is technically versed enough to cancel the form submission (and HTTP payload) in order to attach a different file, then that edge-case is not supported here. Lastly, all forms submitted via HTTP GET are idempotent by definition of HTTP standards, so excluded in this implementation.
Type:

(static) formUpdated :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches formUpdated behaviors.
detach Drupal~behaviorDetach Detaches formUpdated behaviors.
Triggers the 'formUpdated' event on form elements when they are modified.
Type:
Fires:

(static) machineName :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches machine-name behaviors.
Attach the machine-readable name form element behavior.
Type:

(static) setTimezone :Drupal~behavior

Source:
Set the client's system time zone as default values of form fields.
Type:

(static) states :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches states behaviors.
Attaches the states.
Type:

(static) tableDrag :Drupal~behavior

Source:
Drag and drop table rows with field manipulation. Using the drupal_attach_tabledrag() function, any table with weights or parent relationships may be made into draggable tables. Columns containing a field may optionally be hidden, providing a better user experience. Created tableDrag instances may be modified with custom behaviors by overriding the .onDrag, .onDrop, .row.onSwap, and .row.onIndent methods. See blocks.js for an example of adding additional functionality to tableDrag.
Type:

(static) tableHeader :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches the sticky table header behavior.
Attaches sticky table headers.
Type:

(static) tableResponsive :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches tableResponsive functionality.
Attach the tableResponsive function to Drupal.behaviors.
Type:

(static) tableSelect :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches tableSelect functionality.
Initialize tableSelects.
Type:

(static) verticalTabs :Drupal~behavior

Source:
Properties:
Name Type Description
attach Drupal~behaviorAttach Attaches behaviors for vertical tabs.
This script transforms a set of details into a stack of vertical tabs. Each tab may have a summary which can be updated by another script. For that to work, each details element has an associated 'verticalTabCallback' (with jQuery.data() attached to the details), which is called every time the user performs an update to a form element inside the tab pane.
Type: