@@ -42,16 +42,18 @@ var vm = new Vue({
4242
4343### events
4444
45- | props | args | Description |
46- | ----------- | ------- | ------------------------------------------------------- |
47- | ` @change ` | Boolean | notify v-model/listeners that drawer state has changed. |
48- | ` @accept ` | none | emitted when dialog is accepted |
49- | ` @cancel ` | none | emitted when dialog is cancelled |
50- | ` @validate ` | accept | emmited before the dialog is accepted _ (\* )_ |
51-
52- > Note that if you listen to the @validate event, then You must call
53- > the accept argument to finally close the box. Use ` accept(false) ` to
54- > prevent emitting the ` accept ` event and just close.
45+ | props | args | Description |
46+ | ----------------- | ------- | ------------------------------------------------------- |
47+ | ` @change ` | Boolean | notify v-model/listeners that drawer state has changed. |
48+ | ` @accept ` | none | emitted when dialog is accepted |
49+ | ` @cancel ` | none | emitted when dialog is cancelled |
50+ | ` @validate ` | accept | emitted before the dialog is accepted _ (\* )_ |
51+ | ` @validateCancel ` | cancel | emitted before the dialog is cancelled _ (\* )_ |
52+
53+ > Note that if you listen to the @validate or @validateCancel events, then You must call
54+ > the accept or cancel argument to finally close the box. Use ` accept(false) ` to
55+ > prevent emitting the ` accept ` event and just close, and ` cancel(false) ` to prevent emitting
56+ > the ` cancel ` event.
5557
5658### Custom validation logic
5759
@@ -87,6 +89,29 @@ export default {
8789};
8890```
8991
92+ You can use ` @validateCancel ` to trigger validation logic for the cancel event, as follows:
93+
94+ ``` html
95+ <mdc-dialog ref =" dialog" title =" Dialog" accept =" Accept" cancel =" Decline"
96+ @validateCancel =" onValidateCancel"
97+ >Lorem ipsum dolor sit amet</mdc-dialog >
98+ ```
99+
100+ ``` javascript
101+ export default {
102+ methods: {
103+ onValidateCancel ({ cancel }) {
104+ let isValid = false ;
105+ // custom validation logic here
106+ // ..
107+ if (isValid) {
108+ cancel ();
109+ }
110+ },
111+ },
112+ };
113+ ```
114+
90115### Reference
91116
92117< https://material.io/components/web/catalog/dialogs >
0 commit comments