User Interaction
To specify when the Popover should be shown and hidden, set the showEvent and hideEvent options. These options can accept several events at once as well as an object.
- <img id="image" src="https://www.devexpress.com/DXR.axd?r=9999_17-FD0Id" />
- <dx-popover
- target="#image"
- showEvent="dxhoverstart"
- hideEvent="dxhoverend">
- <div *dxTemplate="let data of 'content'">
- <p>Popover content</p>
- </div>
- </dx-popover>
- import { DxPopoverModule } from "devextreme-angular";
- // ...
- export class AppComponent {
- // ...
- }
- @NgModule({
- imports: [
- // ...
- DxPopoverModule
- ],
- // ...
- })
The Popover can also be hidden when a user clicks outside it or presses the Back button on the device. To control this behavior of the Popover, use the closeOnBackButton and closeOnOutsideClick options.
- <img id="image" src="https://www.devexpress.com/DXR.axd?r=9999_17-FD0Id" />
- <dx-popover
- target="#image"
- showEvent="dxhoverstart"
- hideEvent="dxhoverend"
- [closeOnBackButton]="false"
- [closeOnOutsideClick]="false">
- <div *dxTemplate="let data of 'content'">
- <p>Popover content</p>
- </div>
- </dx-popover>
- import { DxPopoverModule } from "devextreme-angular";
- // ...
- export class AppComponent {
- // ...
- }
- @NgModule({
- imports: [
- // ...
- DxPopoverModule
- ],
- // ...
- })
API
To show or hide the Popover programmatically, call the show() or hide() method. The same thing can be done using the toggle(showing) method. Pass true or false to this method to show or hide the Popover, respectively. This approach is more typical of jQuery and ASP.NET MVC Controls.
The show() method called without arguments shows the Popover for the target specified beforehand. If you need to change the target once, call the show(target) method.
With Angular, AngularJS, or Knockout, use a different technique. Bind the visible property of the Popover widget to a component property (in Angular), a scope property (in AngularJS), or an observable variable (in Knockout). After that, change them, and the Popover will appear or disappear.
- <img id="image" src="https://www.devexpress.com/DXR.axd?r=9999_17-FD0Id" />
- <dx-popover
- target="#image"
- [visible]="isPopoverVisible">
- <div *dxTemplate="let data of 'content'">
- <p>Popover content</p>
- </div>
- </dx-popover>
- <dx-button
- text="Show the Popover"
- (onClick)="isPopoverVisible = true">
- </dx-button>
- <dx-button
- text="Hide the Popover"
- (onClick)="isPopoverVisible = false">
- </dx-button>
- import { DxPopoverModule, DxButtonModule } from "devextreme-angular";
- // ...
- export class AppComponent {
- isPopoverVisible: boolean = false;
- }
- @NgModule({
- imports: [
- // ...
- DxPopoverModule
- ],
- // ...
- })
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 widget, assign it to the corresponding onEventName option when you configure the widget.
- <dx-popover ...
- (onShowing)="onShowing($event)"
- (onShown)="onShown($event)"
- (onHiding)="onHiding($event)"
- (onHidden)="onHidden($event)">
- </dx-popover>
- import { DxPopoverModule } from "devextreme-angular";
- // ...
- export class AppComponent {
- 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
- }
- }
- @NgModule({
- imports: [
- // ...
- DxPopoverModule
- ],
- // ...
- })
If you are going to change event handlers at runtime, or if you need to attach several handlers to a single event, subscribe to the events using the on(eventName, eventHandler) method. This approach is more typical of jQuery.
- var hiddenEventHandler1 = function (e) {
- // First handler of the "hidden" event
- };
- var hiddenEventHandler2 = function (e) {
- // Second handler of the "hidden" event
- };
- $("#popoverContainer").dxPopover("instance")
- .on("hidden", hiddenEventHandler1)
- .on("hidden", hiddenEventHandler2);
See Also
- Handle Events: jQuery | Angular | AngularJS | Knockout | Vue | React | ASP.NET MVC
- Popover - Customize the Content
- Popover - Resize and Relocate
- Popover Demos
If you have technical questions, please create a support ticket in the DevExpress Support Center.