HTTPS SSH

A plain native button widget for dojo

The goal here is to provide a plain HTML button that can be used as a dojo widget.

Basic usage:

nclicked = 0; // intentionally global
require(
    ["zc.dojo.NativeButton", "dojo/_base/window"],
    function (NativeButton, win) {
        new NativeButton(
            {
                label: "Hello world!",
                "class": "myclass",
                onClick: function (e) {
                    nclicked += 1;
                }
            }).placeAt(win.body());
});

You'll typically want to specify at least a label and an onClick handler. You can specify other attributes, such as "class" and id.

You can specify en existing node to use using an id. For example, if the page contained:

<span id="wasspan">I was there</span>

Now, if we create a button using this node, we don't have to place it, and it will take over the original node, but retain it's orginal id and content:

require(
    ["zc.dojo.NativeButton"],
    function (NativeButton) {
        new NativeButton({
                "class": "myclass",
                onClick: function (e) {
                    nclicked -= 1;
                }
            }, "wasspan");
});

And the node wil lend up looking like:

<button id="wasspan" class="myclass">I was there</button>

The button class gets defined as a global, zc.dojo.NativeButton, so it can be instantiated declaratively.