I recently hit this snag when working with Dojo. Basically I wanted to set the checked status of a checkbox on a webpage programmatically. Simple you might think? Apparently not as easy as it should be.
Interaction with checkboxes has changed slightly in Dojo 1.1 (apparently) but
myCheckbox.setValue(true) should be valid. When calling
dojo.byId('my-checkbox-id').setValue(true), I was getting an error saying the method didn’t exist. The object was definitely the checkbox as I could determine the correct checked state from that object (
myCheckbox.checked) so I was very confused. I then remembered another way to access objects with Dojo is using the HTML attribute ‘
jsId='myCheckbox' and then called
myCheckbox.setValue(true) and it worked!
dojo.byId() is a different bit of code and creates an object pointing to the DOM checkbox object in a different way. Very strange but at least there’s the workaround above…