King King - 1 month ago 7x
Javascript Question

Cannot read property 'set' of undefined in dojo

i'm using the set property for enabling and disabling the button based on the checkbox click..while compiling getting error like this. "Cannot read property 'set' of undefined" can anyone please help.thanks in advance.


if(dojo.byId('pickLstValChkbox').checked === false){
dijit.byId('isK9Acccepted').set('disabled', true)
dijit.byId('isK9Acccepted').set('disabled', false)


<input type="CHECKBOX" name="" dojoType='dijit.form.CheckBox' id="pickLstValChkbox" value="CONFIRM_CHECKED">
<button class="defaultButton" dojoType="dijit.form.Button" id="isK9Acccepted">Accept</button>


First thing is to call parser.parse() ( create and render dijits )

Then to access your dijit you have to use dojo/ready to ensure that all dijit's are loaded and rendered

In your case you want that when the checkbox is checked (unchecked ), you enable (disable) the button so, you have to use a change event on the checkbox dijit

note that modern dojo uses data-dojo-* [ type, event , id ]insted of dojoType or dojoEvent ... in its html attrib .

here is a fiddle that may help you : Fiddle