In my widget, I have successfully hooked up a dojo on-click listener to an HTML Select control using data-dojo-attach-event like so...
<select id="cboPaletteItemChooser" data-dojo-attach-event="onclick:myFunc" >
... more code ...
But what I really want to do is also add an event handler for the onchange event as well (in addition to onclick). How can I add two or more event handlers?
something like this doesn't work
<select id="cboPaletteItemChooser" data-dojo-attach-event="onclick:myFunc;onchange:myFunc2" >
Solved! Go to Solution.
In the Dojo documentation, the section on Event Attachments uses a slightly different syntax.
This is a comma-delimited string of key/value pairs (separated by colon); the key is the native DOM event to attach a handler to, and the value is the name of your widget's method to execute when that event is fired
.
data-dojo-attach-event="onmouseenter:_onHover,onmouseleave:_onUnhover,ondijitclick:_onClick"
River,
I never figured out if this could be done so I just added the additional events in my code and not the html.
Thanks Robert - I'm such a Dojo and Javascript newbie, I'm not quite sure what that would look like. Do you somehow attach an event handler in widget.js using Dojo? Could you provide a code snip?
In the Dojo documentation, the section on Event Attachments uses a slightly different syntax.
This is a comma-delimited string of key/value pairs (separated by colon); the key is the native DOM event to attach a handler to, and the value is the name of your widget's method to execute when that event is fired
.
data-dojo-attach-event="onmouseenter:_onHover,onmouseleave:_onUnhover,ondijitclick:_onClick"
Thank you Ken - that worked perfectly. I guess it was just the pattern of using semi-colons for css delimiters that had me confused. Thanks for the link to the Dojo documentation too (it can be a little overwhelming!).