DISQUS

DISQUS Hello! Gareth Jones is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Jump to original thread »
Author

Dojo checkboxes

Started by garethj · 1 year ago

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), ... Continue reading »

6 comments

  • You need to use dijit.byId instead of dojo.byId. Then you're in business without setting a jsId for every widget.
  • Ah, thanks very much. For anyone interested, I've discovered the reason for this (copied from http://tinyurl.com/58oqey ):

    Here's the difference: dijit.byId() returns a Dijit widget instance - technically, an instance of dijit._Widget or one of its subclasses like dijit.Toolbar or dijit.TreeNode.

    So here's the way to remember it:

    * If you need a DOM Node, use dojo.byId. You need a DOM node anytime you call a standard browser function, change a standard property, etc.
    * If you need a widget, use dijit.byId. From it you can access all of the attributes, methods and extension points listed in Part 2.

    Useful stuff to know when using digit widgets.
  • Have you tried using dijit.byId instead of dojo.byId?
  • Opps, didn't notice the other reply. Sorry.
  • No problem Ryan - thanks for posting anyway :)
  • I also ran into a similar issue just now. As I've found out, using dijit.byId is for when you're using dojo widgets. As I wasn't, I had to work on the DOM level, so I used dojo.byId("controlid").checked to see if it was checked.

Add New Comment

Returning? Login