Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#12412 closed enhancement (wontfix)

ToggleButton: onChange arguments could be more useful

Reported by: Colin Snover Owned by: anonymous
Priority: high Milestone: tbd
Component: Dijit - Form Version: 1.6.0
Keywords: Cc:
Blocked By: Blocking:


Currently, only the boolean value of the checked attribute is provided when the onChange event is fired, which is worthless in situations where the same event handler is bound to multiple different checkboxes/radiobuttons/whatever, which I imagine is a fairly common case. I’m not sure what the best option here would be; either adding value as a second argument or provide the element itself as an argument or something else.

Change History (4)

comment:1 Changed 11 years ago by bill

Component: GeneralDijit
Resolution: wontfix
Status: newclosed
Summary: ToggleButton onChange arguments could be more usefulToggleButton: onChange arguments could be more useful

The widget itself is already available as "this":

function myOnChangeHandler(checked){
    console.log( + ": value= " + checked);

comment:2 Changed 11 years ago by Colin Snover

dojo.declare('foo', [ dijit._Widget, dijit._Templated ], {

    templateString: '<div><input dojoType="dijit.form.Checkbox" dojoAttachEvent="onChange:_foo"></div>',

    _foo: function () {
        console.log(this); // foo
function myOnChangeHandler(checked){
    console.log(this); // window
dojo.connect(checkbox, 'onChange', window, 'myOnChangeHandler');

comment:3 Changed 11 years ago by bill

The dojo.connect() call in your code example should be:

dojo.connect(checkbox, 'onChange',  myOnChangeHandler);

comment:4 Changed 11 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.