Vue Popover - Show and Hide the Popover

User Interaction

To specify when the Popover should be shown and hidden, set the showEvent and hideEvent properties. These properties can accept several events at once as well as an object.

  • <template>
  • <div>
  • <img id="image" src="https://url/to/an/image" />
  • <DxPopover
  • target="#image"
  • show-event="dxhoverstart"
  • hide-event="dxhoverend">
  • <template #content>
  • <p>Popover content</p>
  • </template>
  • </DxPopover>
  • </div>
  • </template>
  •  
  • <script>
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { DxPopover } from 'devextreme-vue/popover';
  •  
  • export default {
  • components: {
  • DxPopover
  • }
  • }
  • </script>

View Demo

The Popover can also be hidden when a user clicks outside it. To control this behavior of the Popover, use the hideOnOutsideClick property.

  • <template>
  • <div>
  • <img id="image" src="https://url/to/an/image" />
  • <DxPopover
  • target="#image"
  • show-event="dxhoverstart"
  • hide-event="dxhoverend"
  • :hide-on-outside-click="false">
  • <template #content>
  • <p>Popover content</p>
  • </template>
  • </DxPopover>
  • </div>
  • </template>
  •  
  • <script>
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { DxPopover } from 'devextreme-vue/popover';
  •  
  • export default {
  • components: {
  • DxPopover
  • }
  • }
  • </script>

API

NOTE
In this article, the Button UI component is used to demonstrate how to show and hide the Popover. This choice is made for purely demonstrational purposes, and you can do the same operations using another UI component following the same guidelines.

To show or hide the Popover programmatically, bind the visible property of Popover to a component property. After that, change the latter property, and the Popover will appear or disappear.

  • <template>
  • <div>
  • <img id="image" src="https://url/to/an/image" />
  • <DxPopover
  • target="#image"
  • v-model:visible="isPopoverVisible">
  • <template #content>
  • <p>Popover content</p>
  • </template>
  • </DxPopover>
  • <DxButton
  • text="Show the Popover"
  • @click="showPopover"
  • />
  • <DxButton
  • text="Hide the Popover"
  • @click="hidePopover"
  • />
  • </div>
  • </template>
  •  
  • <script>
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { DxPopover } from 'devextreme-vue/popover';
  • import { DxButton } from 'devextreme-vue/button';
  •  
  • export default {
  • components: {
  • DxPopover,
  • DxButton
  • },
  • data() {
  • return {
  • isPopoverVisible: false
  • }
  • },
  • methods: {
  • showPopover() {
  • this.isPopoverVisible = true;
  • },
  • hidePopover() {
  • this.isPopoverVisible = false;
  • }
  • }
  • }
  •  
  • </script>

Events

To execute certain commands before or after the Popover was shown/hidden, handle the showing, shown, hiding or hidden event. If the event handling function is not going to be changed during the lifetime of the UI component, assign it to the corresponding onEventName property when you configure the UI component.

  • <template>
  • <DxPopover ...
  • @showing="onShowing"
  • @shown="onShown"
  • @hiding="onHiding"
  • @hidden="onHidden"
  • />
  • </template>
  •  
  • <script>
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { DxPopover } from 'devextreme-vue/popover';
  •  
  • export default {
  • components: {
  • DxPopover
  • },
  • methods: {
  • onShowing(e) {
  • // Handler of the 'showing' event
  • },
  • onShown(e) {
  • // Handler of the 'shown' event
  • },
  • onHiding(e) {
  • // Handler of the 'hiding' event
  • },
  • onHidden(e) {
  • // Handler of the 'hidden' event
  • }
  • }
  • }
  • </script>
See Also