This repository was archived by the owner on Nov 19, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
src/guides/v2.3/javascript-dev-guide/widgets Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -385,6 +385,47 @@ The following example shows how to initialize the modal widget and pass options
385
385
</div >
386
386
```
387
387
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
+
388
429
### Result
389
430
390
431
The result is a modal and a button (_ Click Here_ ) that opens the modal.
You can’t perform that action at this time.
0 commit comments