Skip to content

Commit a5ee8ee

Browse files
authored
Merge branch 'master' into ds_whatsnew
2 parents 085f7f3 + 0475f13 commit a5ee8ee

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Loading

guides/v2.1/javascript-dev-guide/widgets/widget_confirm.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,65 @@ The confirmation widget implements the following events:
121121

122122
The keyboard navigation for the alert windows is similar to the [navigation of the modal widget].
123123

124+
## Code Sample
125+
126+
### Code sample of standalone initialization
127+
128+
```html
129+
<div class="confirmation-modal-content">
130+
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
131+
</div>
132+
133+
<script>
134+
require([
135+
'jquery',
136+
'Magento_Ui/js/modal/confirm'
137+
], function ($, confirmation) {
138+
'use strict';
139+
140+
confirmation({
141+
title: $.mage.__('Confirmation Title'),
142+
content: $('.confirmation-modal-content'),
143+
actions: {
144+
confirm: function(){}, //callback on 'Ok' button click
145+
cancel: function(){}, //callback on 'Cancel' button click
146+
always: function(){}
147+
}
148+
});
149+
});
150+
</script>
151+
```
152+
153+
### Code sample of initialization on an element
154+
155+
```html
156+
<div class="confirmation-modal-content">
157+
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
158+
</div>
159+
160+
<script>
161+
require([
162+
'jquery',
163+
'Magento_Ui/js/modal/confirm'
164+
], function ($) {
165+
'use strict';
166+
167+
$('.confirmation-modal-content').confirm({
168+
title: 'Confirmation Title',
169+
actions: {
170+
confirm: function(){}, //callback on 'Ok' button click
171+
cancel: function(){}, //callback on 'Cancel' button click
172+
always: function(){}
173+
}
174+
});
175+
});
176+
</script>
177+
```
178+
179+
## Result
180+
181+
![Confirmation Widget]({{ site.baseurl }}/common/images/widget/confirm-widget-result.png)
182+
124183
[Magento modal widget]: {{page.baseurl}}/javascript-dev-guide/widgets/widget_modal.html
125184
[`<Magento_Ui_module_dir>/view/base/web/js/modal/confirm.js`]: {{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Ui/view/base/web/js/modal/confirm.js
126185
[Magento Admin Pattern Library, the Slide-out Panels, Modal Windows, and Overlays topic.]: {{page.baseurl}}/pattern-library/containers/slideouts-modals-overlays/slideouts-modals-overalys.html#modals

0 commit comments

Comments
 (0)