Dijit.form.button with img src in software

Is there any way to add the img src tag to the programmer for dijit.form.button?

In declarative, we can do something like this:

<div dojoType="dijit.form.Button"><img src="images/img.png"/></div>

In this case, the dijit button is completely replaced by the image.

If I try something like this, the button does not replace the image, but appears in:

var button = new dijit.form.Button({
        showLabel : false,
        label : "Validate",
        iconClass : "alphaIcon validateIcon",   
    })

Your help will be greatly appreciated.

Thanks in advance

+3
source share
3 answers

I think your approach should be to do exactly what you did and create custom css to change the look.

myIconButton.dijitButton .dijitButtonNode {
  border: 0;
  background-image: none;
  background-color: transparent;
  box-shadow: none;
}

var button = ... // same as above
dojo.addClass(button.domNode, 'myIconButton');

To answer your question, you can create your own button widget with a custom template in which there was only an image source.

dojo.declare("MyIconButton", [Button], {
  templateString: '<div><img src="${imageSrc}"></img></div>'
});

. , , MyIconButton, Button .

0

,

this.button1.attr('label','<img src="' + this.constants.packagePrefix + '/images/button1.gif"/>');

: http://mail.dojotoolkit.org/pipermail/dojo-interest/2009-August/038353.html

0

I use a class with a background for buttons. This really made it difficult to dynamically determine the image. So, I have successfully used this:

domStyle.set(myButton.iconNode, 'background-image', 'url(images/icon.png)');

The focus was on iconNode, not domNode or containerNode.

0
source

All Articles