Button

The Button widget is a simple button that performs specified commands when a user clicks it.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/button
Button interactive configuration
Copy Code
Copy to Codepen
$("#button").dxButton({
});

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

  • jQuery
    Use the dxButton jQuery plug-in.

    HTML
    <div id="button"></div>
    JavaScript
    $("#button").dxButton({
        text: 'Click me',
        onClick: function() {
            alert('Button clicked');
        }
    });
  • Knockout
    Add a div element and apply the dxButton binding to this element.

    JavaScript
    var myViewModel = {
        buttonClicked: function() {
            alert('Button clicked');
        }
    }
    ko.applyBindings(myViewModel);
    HTML
    <div data-bind="dxButton: {
        text: 'Click me',
        onClick: buttonClicked
    }"></div>
  • AngularJS
    Add a div element and apply the dx-button directive to this element.

    JavaScript
    var myApp = angular.module('myApp', ['dx']);
    myApp.controller("demoController", function ($scope) {
        $scope.buttonClicked = function () {
            alert('Button clicked');
        };
    });
    angular.element(document).ready(function () {
        angular.bootstrap(document, ['myApp']);
    });
    HTML
    <div dx-button="{
        text: 'Click me',
        onClick: buttonClicked
    }"></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 the detailed information on principles of working with the widget in the dxButton section of the Individual Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the Button widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.

Default Template

This section lists the fields of a context object available in a button template.

By default, a predefined template is applied to display the widget. This template is based on the fields of the template context object. Below is the list of these fields. If the default item template is not appropriate for your task, implement a custom template based on these fields or fields of the view model.

See Also