I'm relatively new to Dojo and trying to get the hang of dijits. After consulting the docs for Dojo's dijit/form/Button widget here:
http://dojotoolkit.org/reference-guide/1.9/dijit/form/Button.html
I attempted to create a button showing only an icon (showLabel: false). That attempt can be seen in this fiddle:
http://jsfiddle.net/msweeney/23Mxh/
or assembled from the code:
HTML
<body>
<button type="button" id="testButton"></button>
</body>
CSS
.plusIcon {
background-image: url("http://png-2.findicons.com/files/icons/2152/snowish/128/gtk_add.png");
background-position: center;
background-repeat: no-repeat;
height: 19px;
width: 19px;
}
JS
require(["dojo/parser", "dijit/form/Button", "dojo/domReady!"],
function (parser, Button) {
parser.parse();
var testButton = new Button({
label: "test button",
showLabel: false,
iconClass: "plusIcon",
onClick: function () {
alert("test button clicked")
}
}, "testButton");
testButton.startup();
});
I can't seem to figure out what I'm doing wrong here. In particular:
- Why doesn't the icon show up?
- What is causing the black dot to appear?
- Why does the label still show up even when showLabel is set to false?
- Why isn't the label inside the button?
Note: I'd be glad to show pictures to illustrate what I'm getting and what I'd like to be getting, but I don't have enough reputation yet.