#5391 closed defect (invalid)
Textarea 1.0.1: Event handling does not work
Reported by: | guest | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Dijit - Form | Version: | 1.0 |
Keywords: | Textarea events | Cc: | |
Blocked By: | Blocking: |
Description (last modified by )
I cannot get Javascript Events to work with dijit.form.Textarea. Dojo Versions are 0.9, 1.0 and 1.0.1.
Below is a Testcase that creates both a textarea and a textbox. Textbox works fine, but Textarea event are only fired if the surrounding box is clicked. It should be fired when the text is clicked as well.
<head> <title>Dojo Events are Great</title> <script type="text/javascript" src="http://o.aolcdn.com/dojo/1.0.0/dojo/dojo.xd.js"></script> <script type="text/javascript"> function foo(){ alert('foo') } function fee(){ alert('foe') } </script> <script type="text/javascript"> dojo.require("dijit.form.Textarea"); dojo.require("dijit.form.TextBox"); dojo.addOnLoad(function() { dojo.parser.parse(dojo.byId('container')); areaNode = dojo.byId("areaid"); dojo.connect(areaNode, 'onclick', foo); boxNode = dojo.byId("boxid"); dojo.connect(boxNode, 'onclick', fee); }); </script> <body> <input dojoType='dijit.form.Textarea' name='area' id='areaid' value='a comment' ></input> <input dojoType='dijit.form.TextBox' name='box' id='boxid' value='a box' ></input> </body> </html>
Change History (5)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Component: | General → Dijit |
---|---|
Description: | modified (diff) |
Owner: | anonymous deleted |
comment:3 Changed 13 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
What dmachi said is correct. You would need to change the code as he suggested, because widgets and dom nodes are not the same thing, but still onClick is not supported on anything besides buttons. Eventually we'll support at least onfocus and onblur on input widgets like TextArea? (see #5327), but not sure if we'll ever support more esoteric callbacks like onclick or onkeyup.
comment:4 Changed 13 years ago by
onFocus would be just fine, but that does not work either.
From my point of view, something that works with default HTML textarea code should also work with dijit Textarea.
And furthermore, the page http://www.dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/event-system/simple-connections-dojo-connect does not at all mention that the dojo event system is limited to Buttons, but actually gives a standard HTML Link as an example.
comment:5 Changed 10 years ago by
Component: | Dijit → Dijit - Form |
---|
This code doesn't look to be correct.
2.dojo.byId("areaid") will retrieve a domNode instance, but it looks like that is intended to be a widget not a domNode. dijit.byId("areaid"); would be used instead and retruns a Widget not a domNode.