UI Widgets Toast

The toast message widget.

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

The main purpose of the Toast widget is to show a toast message containing specified text.

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

  • jQuery
    Use the dxToast jQuery plug-in.

    HTML
    <div id="toast"></div>
    JavaScript
    $("#toast").dxToast({
        message: 'The toast message',
        type: 'success',
        displayTime: 3000
    });
  • Knockout
    Add a div element and apply the dxToast binding to this element.

    HTML
    <div data-bind="dxToast: {
        message: 'The toast message',
        type: 'success',
        displayTime: 3000
    }"></div>
  • AngularJS
    Add a div element and apply the dx-toast directive to this element.

    HTML
    <div dx-toast="{
        message: 'The toast message',
        type: 'success',
        displayTime: 3000
    }"></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 dxToast section of the Overlay Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery
<div ng-controller="demoController" style="height: 100%;">
    <div class="button" dx-button="{ 
        text: 'Show toast',
        onClick: showToast
    }"></div>
    <div dx-toast="{
        message:'Toast message',
        type:'success',
        displayTime: 2000,
        bindingOptions: {
            visible: 'toastVisible'
        }
    }"></div>
</div>
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.toastVisible = false;
    $scope.showToast = function () {
        $scope.toastVisible = true;
    };
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
body{
    text-align: center;
}
.dx-button{
    margin: 10px;
}
<div class="button" data-bind="dxButton: { 
    text: 'Show toast',
    onClick: showToast
}"></div>
<div data-bind="dxToast:{
    message:'Toast message',
    type:'success',
    displayTime: 2000,
    visible: toastVisible
}"></div>
var myViewModel = {
    toastVisible: ko.observable(false),
    showToast: function(){
        this.toastVisible(true);
    }
}
ko.applyBindings(myViewModel);
body{
    text-align: center;
}
.dx-button{
    margin: 10px;
}
<div class="button" id="showToastButton"></div>
<div id="myToast"></div>
$("#myToast").dxToast({
    message: 'Toast message',
    type: 'success',
    displayTime: 2000
});
$("#showToastButton").dxButton({
    text: 'Show toast',
    onClick: function () {
        $("#myToast").dxToast("instance").show();
    }
});
body{
    text-align: center;
}
.dx-button{
    margin: 10px;
}

Configuration

An object defining configuration options for the Toast widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.