UI Widgets Popup

A widget that displays required content in a popup window.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/popup
Popup interactive configuration
Copy code
$("#popup").dxPopup({
});

The Popup widget is a window overlaying the current view. It displays data located inside the HTML element representing the widget. The widget can have a title, and can be shown in full-screen mode. Specify the title text using the title option, and assign true to the showTitle option to display the window title. The full-screen mode's availability is specified by the fullScreen option.

You can create a widget using one of the following approaches.

  • jQuery
    Use the dxPopup jQuery plug-in.

    HTML
    <div id="popup"></div>
    JavaScript
    $("#popup").dxPopup({
        showTitle: true,
        title: 'Popup title'
    });
  • Knockout
    Add a div element and apply the dxPopup binding to this element.

    HTML
    <div data-bind="dxPopup: {
        showTitle: true,
        title: 'Popup title'
    }"></div>
  • AngularJS
    Add a div element and apply the dx-popup directive to this element.

    HTML
    <div dx-popup="{
        showTitle: true,
        title: 'Popup title'
    }"></div>

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the Installation article.

You can find detailed information on the principles of working with the widget in the dxPopup section of the Overlay Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery
<div ng-controller="demoController">
    <div dx-button="{ text:'Show popup', onClick:showPopup }"></div>
    <div dx-popup="{
        fullScreen: true,
        bindingOptions: {
            visible:'popupVisible'
        }
    }">
        <div data-options="dxTemplate:{ name: 'title' }">
            <h1>{{popupTitle}}</h1>
            <div dx-check-box="{
                text: 'Show &quot;Hide popup&quot; button',
                bindingOptions: { 
                    value: 'buttonVisible'
                }
            }"></div>
        </div>
        <div data-options="dxTemplate:{ name: 'content' }">
            <p>The popup content.</p>
            <div dx-button="{
                text: 'Hide popup',
                onClick: hidePopup,
                bindingOptions: {
                    visible: 'buttonVisible'
                }
            }"></div>
        </div>
    </div>
</div>
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.popupTitle = "My popup";
    $scope.buttonVisible = true;
    $scope.popupVisible = false;
    $scope.showPopup = function () {
        $scope.popupVisible = true;
    };
    $scope.hidePopup = function () {
        $scope.popupVisible = false;
    };
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
body {
    text-align: center;
}
.dx-checkbox{
    margin-top: 5px;
}
.dx-button{
    margin-top: 25px;
}
.dx-popup-wrapper .dx-button{
    margin-top: 25px;
}
.dx-popup-title{
    border-bottom: solid 2px red;
    padding-bottom: 10px;
}
<div data-bind="dxButton:{ text:'Show popup', onClick:showPopup }"></div>
<div data-bind="dxPopup:{
    fullScreen: true,
    visible:popupVisible
}">
    <div data-options="dxTemplate:{ name: 'title' }">
        <h1 data-bind="text: popupTitle"></h1>
        <div data-bind="dxCheckBox:{
                text: 'Show &quot;Hide popup&quot; button',
                value: buttonVisible
            }"></div>
    </div>
    <div data-options="dxTemplate:{ name: 'content'}">
        <p>The popup content.</p>
        <div data-bind="dxButton: { text: 'Hide popup', onClick: hidePopup, visible: buttonVisible }"></div>
    </div>
</div>
var myViewModel = {
    popupTitle: "My popup",
    buttonVisible: ko.observable(true),
    popupVisible: ko.observable(false),
    showPopup: function () {
        this.popupVisible(true);
    },
    hidePopup: function () {
        this.popupVisible(false);
    }
}
ko.applyBindings(myViewModel);
body {
    text-align: center;
}
.dx-checkbox{
    margin-top: 5px;
}
.dx-button{
    margin-top: 25px;
}
.dx-popup-wrapper .dx-button{
    margin-top: 25px;
}
.dx-popup-title{
    border-bottom: solid 2px red;
    padding-bottom: 10px;
}
<div id="showButton"></div>
<div id="myPopup"></div>
$("#myPopup").dxPopup({
    fullScreen: true,
    titleTemplate: function (titleElement) {
        titleElement.append("<h1>My popup</h1>");
        var showButtonCheckBox = $("<div>");
        showButtonCheckBox.dxCheckBox({
            text: 'Show "Hide popup" button',
            value: true,
            onValueChanged: function (e) {
                $("#hideButton").dxButton("instance").option("visible", e.value);
            }
        });
        titleElement.append(showButtonCheckBox);
    },
    contentTemplate: function (contentElement) {
        contentElement.append("<p>The popup content.</p>");
        var hideButton = $("<div id='hideButton'>").dxButton({
            text: "Hide popup",
            onClick: function () {
                $("#myPopup").dxPopup("instance").hide();
            }
        });
        contentElement.append(hideButton);
        
    }
});
$("#showButton").dxButton({
    text: 'Show popup',
    onClick: function () {
        $("#myPopup").dxPopup("instance").show();
    }
});
body {
    text-align: center;
}
.dx-checkbox{
    margin-top: 5px;
}
.dx-button{
    margin-top: 25px;
}
.dx-popup-wrapper .dx-button{
    margin-top: 25px;
}
.dx-popup-title{
    border-bottom: solid 2px red;
    padding-bottom: 10px;
}

Configuration

An object defining configuration options for the Popup widget.

Methods

This section describes methods used to manipulate the widget.

Events

This section describes events fired by this widget.