All docs
V23.2
24.1
23.2
23.1
22.2
22.1
21.2
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2.
19.1
The page you are viewing does not exist in version 19.1.
18.2
The page you are viewing does not exist in version 18.2.
18.1
The page you are viewing does not exist in version 18.1.
17.2
The page you are viewing does not exist in version 17.2.

jQuery 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.

jQuery
JavaScript
HTML
$(function() {
    $("#popoverContainer").dxPopover({
        target: "#image",
        showEvent: 'dxhoverstart',
        hideEvent: 'dxhoverend'
    });
});
<img id="image" src="https://url/to/an/image" />
<div id="popoverContainer">
    <p>Popover content</p>
</div>
Angular
HTML
TypeScript
<img id="image" src="https://url/to/an/image" />
<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
    ],
    // ...
})
Vue
<template>
    <div>
        <img id="image" src="https://url/to/an/image" />
        <DxPopover 
            target="#image"
            show-event="dxhoverstart"
            hide-event="dxhoverend">
            <template>
                <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>
React
import React from 'react';
import 'devextreme/dist/css/dx.light.css';

import { Popover } from 'devextreme-react/popover';

const renderContent = () => {
    return (
        <p>Popover content</p>
    );
};

class App extends React.Component {
    render() {
        return (
            <div>
                <img id="image" src="https://url/to/an/image" />
                <Popover
                    target="#image"
                    showEvent="dxhoverstart"
                    hideEvent="dxhoverend"
                    contentRender={renderContent}
                />
            </div>
        );
    }
}

export default App;
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().Popover()
    .Target("#image")
    .ShowEvent("dxhoverstart")
    .HideEvent("dxhoverend")
    .ContentTemplate(@<text>
        <p>Popover content</p>
    </text>)
)
<img id="image" src="https://url/to/an/image" />

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.

jQuery
JavaScript
HTML
$(function() {
    $("#popoverContainer").dxPopover({
        target: "#image",
        showEvent: 'dxhoverstart',
        hideEvent: 'dxhoverend',
        hideOnOutsideClick: false
    });
});
<img id="image" src="https://url/to/an/image" />
<div id="popoverContainer">
    <p>Popover content</p>
</div>
Angular
HTML
TypeScript
<img id="image" src="https://url/to/an/image" />
<dx-popover
    target="#image"
    showEvent="dxhoverstart"
    hideEvent="dxhoverend"
    [hideOnOutsideClick]="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
    ],
    // ...
})
Vue
<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>
                <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>
React
import React from 'react';
import 'devextreme/dist/css/dx.light.css';

import { Popover } from 'devextreme-react/popover';

const renderContent = () => {
    return (
        <p>Popover content</p>
    );
};

class App extends React.Component {
    render() {
        return (
            <div>
                <img id="image" src="https://url/to/an/image" />
                <Popover
                    target="#image"
                    showEvent="dxhoverstart"
                    hideEvent="dxhoverend"
                    contentRender={renderContent}
                    hideOnOutsideClick={false}
                />
            </div>
        );
    }
}

export default App;
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().Popover()
    .Target("#image")
    .ShowEvent("dxhoverstart")
    .HideEvent("dxhoverend")
    .ContentTemplate(@<text>
        <p>Popover content</p>
    </text>)
    .HideOnOutsideClick(false)
)
<img id="image" src="https://url/to/an/image" />

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.
jQuery

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.

JavaScript
HTML
$(function() {
    $("#popoverContainer").dxPopover({
        target: "#image"
    });

    $("#showButton").dxButton({
        text: "Show the Popover", 
        onClick: function () {
            $("#popoverContainer").dxPopover("show");
            // ===== or =====
            $("#popoverContainer").dxPopover("toggle", true);
        } 
    });

    $("#hideButton").dxButton({
        text: "Hide the Popover", 
        onClick: function () {
            $("#popoverContainer").dxPopover("hide");
            // ===== or =====
            $("#popoverContainer").dxPopover("toggle", false);
        } 
    });
});
<img id="image" src="https://url/to/an/image" />
<div id="popoverContainer">
    <p>Popover content</p>
</div>
<div id="showButton"></div>
<div id="hideButton"></div>
ASP.NET MVC Controls

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.

Razor C#
@(Html.DevExtreme().Popover()
    .ID("popover")
    .Target("#image")
    .ContentTemplate(@<text>
        <p>Popover content</p>
    </text>)
)
<img id="image" src="https://url/to/an/image" />

@(Html.DevExtreme().Button()
    .ID("showButton")
    .Text("Show the Popover")
    .OnClick("showPopover")
)

@(Html.DevExtreme().Button()
    .ID("hideButton")
    .Text("Hide the Popover")
    .OnClick("hidePopover")
)

<script type="text/javascript">
    function showPopover () {
        $("#popover").dxPopover("show");
        // ===== or =====
        $("#popover").dxPopover("toggle", true);
    }

    function hidePopover () {
        $("#popover").dxPopover("hide");
        // ===== or =====
        $("#popover").dxPopover("toggle", false);
    } 
</script>
jQuery

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.

JavaScript
$(function() {
    // ...
    $("#showButton").dxButton({
        text: "Show the Popover", 
        onClick: function () {
            $("#popoverContainer").dxPopover("show", "#newTarget");
        } 
    });
});
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.

Razor C#
// ...

<script type="text/javascript">
    function showPopover () {
        $("#popover").dxPopover("show", "#newTarget");
    }
    // ...
</script>
Angular

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.

HTML
TypeScript
<img id="image" src="https://url/to/an/image" />
<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
    ],
    // ...
})
Vue

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>
                <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>
React

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

import React from 'react';
import 'devextreme/dist/css/dx.light.css';

import { Popover } from 'devextreme-react/popover';
import { Button } from 'devextreme-react/button';

const renderContent = () => {
    return (
        <p>Popover content</p>
    );
}

class App extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            isPopoverVisible: false
        };

        this.showPopover = this.showPopover.bind(this);
        this.hidePopover = this.hidePopover.bind(this);
    }

    showPopover() {
        this.setState({
            isPopoverVisible: true
        });
    }

    hidePopover() {
        this.setState({
            isPopoverVisible: false
        });
    }

    render() {
        return (
            <div>
                <img id="image" src="https://url/to/an/image" />
                <Popover
                    target="#image"
                    visible={this.state.isPopoverVisible}
                    contentRender={renderContent}
                    onHiding={this.hidePopover}
                />
                <Button
                    text="Show the Popover"
                    onClick={this.showPopover}
                />
                <Button
                    text="Hide the Popover"
                    onClick={this.hidePopover}
                />
            </div>
        );
    }
}

export default App;

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.

jQuery
JavaScript
$(function () {
    $("#popoverContainer").dxPopover({
        // ...
        onShowing: function (e) {
            // Handler of the "showing" event
        },
        onShown: function (e) {
            // Handler of the "shown" event
        },
        onHiding: function (e) {
            // Handler of the "hiding" event
        },
        onHidden: function (e) {
            // Handler of the "hidden" event
        }
    });
});
Angular
HTML
TypeScript
<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
    ],
    // ...
})
Vue
<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>
React
import React from 'react';
import 'devextreme/dist/css/dx.light.css';

import { Popover } from 'devextreme-react/popover';

class App extends React.Component {
    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
    }

    render() {
        return (
            <Popover ...
                onShowing={this.onShowing}
                onShown={this.onShown}
                onHiding={this.onHiding}
                onHidden={this.onHidden}
            />
        );
    }
}

export default App;
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().Popover()
    // ...
    .OnShowing("popover_onShowing")
    .OnShown("popover_onShown")
    .OnHiding("popover_onHiding")
    .OnHidden("popover_onHidden")
)

<script type="text/javascript">
    function popover_onShowing (e) {
        // Handler of the "showing" event
    },
    function popover_onShown (e) {
        // Handler of the "shown" event
    },
    function popover_onHiding (e) {
        // Handler of the "hiding" event
    },
    function popover_onHidden (e) {
        // Handler of the "hidden" event
    }
</script>
jQuery

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.

JavaScript
const hiddenEventHandler1 = function (e) {
    // First handler of the "hidden" event
};

const hiddenEventHandler2 = function (e) {
    // Second handler of the "hidden" event
};

$("#popoverContainer").dxPopover("instance")
    .on("hidden", hiddenEventHandler1)
    .on("hidden", hiddenEventHandler2);
See Also