Skip to content Skip to sidebar Skip to footer

Get Value Of Checkbox In Dojo, With On() Method

Using dojo 1.9, I'm trying to access the value of a checkbox not like in the example in the docs: require(['dijit/form/CheckBox', 'dojo/domReady!'], function(CheckBox){ var c

Solution 1:

And again I made the same mistake - it should be

registry.byId('checkBox').on('change', function(){ 
    var value = this.value; 
});

Solution 2:

dojo/query returns plain dom Nodes of the widgets, and therefore, we cannot attach the "on" event handler, directly to the query result. As you have said, we can use registry.byId(...)

In addition, let me give a suggestion, where the query would return more number of dom nodes.

array.forEach(dojo.query('.classname'),function(node){
  dijit.getEnclosingWidget(node).on('change',function(){
    var value = this.value;
    console.info(value);
  });
});

dijit.getEnclosingWidget(domNode) - will give the immediate parent widget node of the mentioned 'domNode'

Post a Comment for "Get Value Of Checkbox In Dojo, With On() Method"