Click outside

Be notified when a click occurs outside an element.

Usage

Add v-bt-click-outside to an element with a callback to call when a click occurs outside of it:

    TIP

    By default, the event is triggered on the mousedown event. To change it, please read below.

    Event type

    You can control the event type with the eventType option (mousedown by default):

      Callback

      You have to way to get notified:

      1) Via a callback in the options object

      <!-- Either with the function as binding -->
      <div v-bt-click-outside="onClickOutside"></div>
      
      <!-- Or in the options object -->
      <div v-bt-click-outside="{callback: onClickOutside}"></div>
      

      2) Via the click-outside event

      <div v-bt-click-outside @click-outside="onClickOutside"></div>
      

      Options

      Name Description Default
      Type of event to detect outside of the target. mousedown
      Callback to call when an event is detected outside. undefined
      A boolean to enable/disable the directive. true