SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  *  Add `v-click-outside="function"` to your element.
  3.  *  Does not take into account 'touchstart'
  4.  */
  5.  
  6.  export default {
  7.     bind: function (el, binding, vnode) {
  8.         el.event = function (event) {
  9.             if (!(el == event.target || el.contains(event.target))) {
  10.                 vnode.context[binding.expression](event);
  11.             }
  12.         }
  13.         document.body.addEventListener('click', el.event)
  14.     },
  15.     unbind: function (el) {
  16.         document.body.removeEventListener('click', el.event)
  17.     }
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top