I am trying to set the label on a dijit button dynamically but I can't seem to get it to work.
In the JSP there is this div defined:
The javascript to create the button is a as follows:
function toggleUserStatusButton() {
alert("Creating the user status button");
var params = {id:"tusButton",
label:tusButtonLabel,
onClick:toggleUserStatus};
var widget = new dijit.form.Button(params);
dojo.byId("toggleUserStatusButtonDiv").appendChild(widget.domNode);
}
function tusButtonLabel() {
if (activeIndicator.toUpperCase()=="Y"){
dijit.byId("tusButton").value="Deactivate User";
alert("User Status is: " + activeIndicator);
}
else {
dijit.byId("tusButton").value="Activate User";
}
}
alert("Creating the user status button");
var params = {id:"tusButton",
label:tusButtonLabel,
onClick:toggleUserStatus};
var widget = new dijit.form.Button(params);
dojo.byId("toggleUserStatusButtonDiv").appendChild(widget.domNode);
}
function tusButtonLabel() {
if (activeIndicator.toUpperCase()=="Y"){
dijit.byId("tusButton").value="Deactivate User";
alert("User Status is: " + activeIndicator);
}
else {
dijit.byId("tusButton").value="Activate User";
}
}
I keep getting error when it tries to create the button with the dynamically assigned label and it does not create the button.

you are setting the label to
you are setting the label to a function? I think it needs to be a string?
use setLabel to set the
i know its an old thread but wanted to update it incase someone else for looking for a solution.
use dijit.byId(id).setLabel to set the label dynamically.