user1739825
user1739825

Reputation: 820

Dojo : how to set to disable new button

Hi I have trouble setting the new button to disabled. I am using Dojo 1.8

See my code below:-

require(["dojo/parser", "dijit/layout/BorderContainer",
"dijit/form/Button","dojo/on","dijit/form/Select",
"dojo/store/Memory", "dojo/request","dojo/domReady!"
],
function(parser, BorderContainer, Button, on, Select, Memory, request)
{

var btn4 = new Button // Button, not button
({
    label: "Number of cards",
    this.set("disabled", false) // This code that disables the button
    },"btn4"); 
btn4.startup();
})

I cannot find help in Dojo or google for it.

Upvotes: 11

Views: 22059

Answers (2)

Web Devie
Web Devie

Reputation: 1225

In Dojo many things are other as you would expect.

Button have method setDisabled:

btn4.setDisabled(true) // disable
btn4.setDisabled(false) // enable

Upvotes: 16

Lucas
Lucas

Reputation: 8113

First, trying to call this.set() within the argument list of a dijit does not make sense because the dijit has not been created yet. Second, the first parameter to a dijit is always a standard javascript object with key/value pairs. Trying to insert a function call in the middle of an object declaration is simply a syntax error in the code itself.

Finally, there is no need to try using the dijit's setter at all. Just set disabled: true in your argument list to the Button dijit.

var btn4 = new Button({
    label: "Number of cards",
    disabled: true,
}, "btn4"); 

See this Fiddle.

Upvotes: 7

Related Questions