File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 9
9
Sometimes you need to detect clicks ** outside** of the element (to close a modal
10
10
window or hide a dropdown select). There is no native event for that, and Vue.js
11
11
does not cover you either. This is why ` vue-clickaway ` exists. Please check out
12
- the [ demo] ( https://jsfiddle.net/simplesmiler/4w1cs8u3/ ) before reading further.
12
+ the [ demo] ( https://jsfiddle.net/simplesmiler/4w1cs8u3/150/ ) before reading further.
13
13
14
14
## Requirements
15
15
@@ -78,7 +78,14 @@ export default {
78
78
1 . Pay attention to the letter case. ` onClickaway ` turns into ` v-on-clickaway ` ,
79
79
while ` onClickAway ` turns into ` v-on-click-away ` .
80
80
2 . Prior to ` vue@^2.0 ` , directive were able to accept statements.
81
- This is no longer the case.
81
+ This is no longer the case. If you need to pass arguments, just do
82
+ ` v-on-clickaway="() => away(arg1)" ` .
83
+ 3 . There is a common issue with dropdowns (and modals) inside an element with
84
+ ` v-on-clickaway ` . Some UI libraries chose to implement these UI elements
85
+ by attaching the DOM element directly to the body. This makes clicks on
86
+ a dropped element trigger away handler. To combat that, you have to add
87
+ an extra check in the handler, for where the event originated from.
88
+ See #9 for an example.
82
89
83
90
## License
84
91
You can’t perform that action at this time.
0 commit comments