Button

A button widget.

Included in: dx.phonejs.js, dx.webappjs.js, dx.all.js

The main purpose of the dxButton widget is to perform a specified action when the button is clicked.

You can create a 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>
  • Angular
    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 and Globalize libraries to your application. If you use the Knockout or Angular approach, the Knockout or Angular library is also required.

See Also

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 dxButton widget.

Methods

This section describes methods that can be used to manipulate a widget.

Events

This section describes events exposed by this widget.