You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: guides/v2.1/javascript-dev-guide/widgets/widget_alert.md
+71Lines changed: 71 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,7 @@ The alert widget has the following options:
56
56
-[content]
57
57
-[focus]
58
58
-[title]
59
+
-[modalClass]
59
60
60
61
### `actions` {#alert_actions}
61
62
Widget callbacks.
@@ -105,14 +106,83 @@ The title of the alert window.
105
106
106
107
**Default value**: `''`
107
108
109
+
### `modalClass` {#alert_modalClass}
110
+
The CSS class of the alert window.
111
+
112
+
**Type**: String.
113
+
114
+
**Default value**: `'confirm'`
115
+
108
116
## Events {#alert_events}
109
117
110
118
The alert widget implements a single event: the `always` callback.
119
+
The `always` callback is invoked when a modal window is closed.
111
120
112
121
## Keyboard navigation {#alert_key_navigation}
113
122
114
123
The keyboard navigation for the alert windows is similar to the [navigation of the modal widget].
115
124
125
+
## Code Sample
126
+
127
+
### Code sample of standalone initialization
128
+
129
+
```html
130
+
<divclass="alert-modal-content">
131
+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci amet aut consequuntur culpa cum, distinctio earum harum, iste magnam nobis numquam pariatur tempora ullam vero vitae. Hic ipsam itaque velit.</p>
132
+
</div>
133
+
134
+
<script>
135
+
require([
136
+
'jquery',
137
+
'Magento_Ui/js/modal/alert'
138
+
], function ($, alert) {
139
+
'use strict';
140
+
141
+
alert({
142
+
title:'Alert Title',
143
+
content:$('.alert-modal-content'),
144
+
modalClass:'alert',
145
+
actions: {
146
+
always:function() {
147
+
// do something when the modal is closed
148
+
}
149
+
}
150
+
});
151
+
});
152
+
</script>
153
+
```
154
+
155
+
### Code sample of initialization on an element
156
+
157
+
```html
158
+
<divclass="alert-modal-content">
159
+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci amet aut consequuntur culpa cum, distinctio earum harum, iste magnam nobis numquam pariatur tempora ullam vero vitae. Hic ipsam itaque velit.</p>
0 commit comments