@@ -42,16 +42,18 @@ var vm = new Vue({
42
42
43
43
### events
44
44
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.
55
57
56
58
### Custom validation logic
57
59
@@ -87,6 +89,29 @@ export default {
87
89
};
88
90
```
89
91
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
+
90
115
### Reference
91
116
92
117
< https://material.io/components/web/catalog/dialogs >
0 commit comments