Opened 12 years ago

Closed 12 years ago

Last modified 8 years ago

#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 Adam Peller)

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 12 years ago by Dustin Machi

This code doesn't look to be correct.

  1. I don't see the domnode "container" that the parser is being used against (why not just use parseOnLoad: true in djConfig).

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.

  1. I'm not sure that the textarea or textbox widgets have normal onclick event once create. If so I would expect them to be named onClick instead of onclick.

comment:2 Changed 12 years ago by Adam Peller

Component: GeneralDijit
Description: modified (diff)
Owner: anonymous deleted

comment:3 Changed 12 years ago by bill

Resolution: invalid
Status: newclosed

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 12 years ago by guest

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 8 years ago by bill

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