Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit df11d3e

Browse files
authored
Merge branch 'master' into imgbot
2 parents a58c5ef + c9e9d23 commit df11d3e

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/guides/v2.3/javascript-dev-guide/widgets/widget_modal.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,47 @@ The following example shows how to initialize the modal widget and pass options
385385
</div>
386386
```
387387

388+
The following example shows a PHTML file using the script:
389+
390+
```html
391+
<button id="button">
392+
<span><?= $block->escapeHtml(__('Click me')) ?></span>
393+
</button>
394+
395+
<div id="modal">
396+
<div class="modal-body-content">
397+
<h2><?= $block->escapeHtml(__('Title')) ?></h2>
398+
<p><?= $block->escapeHtml(__('Content')) ?></p>
399+
</div>
400+
</div>
401+
402+
<script type="text/javascript">
403+
require([
404+
"jquery",
405+
"Magento_Ui/js/modal/modal"
406+
],function($, modal) {
407+
408+
var options = {
409+
type: 'popup',
410+
responsive: true,
411+
title: 'Main title',
412+
buttons: [{
413+
text: $.mage.__('Ok'),
414+
class: '',
415+
click: function () {
416+
this.closeModal();
417+
}
418+
}]
419+
};
420+
421+
var popup = modal(options, $('#modal'));
422+
$("#button").click(function() {
423+
$('#modal').modal('openModal');
424+
});
425+
});
426+
</script>
427+
```
428+
388429
### Result
389430

390431
The result is a modal and a button (_Click Here_) that opens the modal.

0 commit comments

Comments
 (0)