Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#5327 closed defect (fixed)

v1.0 TextBox cannot set onfocus & onblur events declaratively

Reported by: guest Owned by: Douglas Hays
Priority: high Milestone: 1.1
Component: Dijit - Form Version: 1.0
Keywords: TextBox Cc:
Blocked By: Blocking:


With v.1.0 dijit.form.TextBox?, cannot set onfocus and onblur events declaratively. With v.1.0 dijit.form.ValidationTextBox?, cannot set onblur event declaratively.

/* line1 */ dojo.connect(dojo.byId("txt1"), "onfocus", func);
/* line2 */ dojo.connect(dojo.byId("txt3"), "onblur", func);

<input type="text" dojoType="dijit.form.TextBox" id="txt1" /> // WORKS WITH line1
<input type="text" dojoType="dijit.form.TextBox" id="txt2" onfocus="alert('focus')" /> // DOES NOT WORK. NOT WITH _onfocus

<input type="text" dojoType="dijit.form.TextBox" id="txt3" /> //WORKS WITH line2
<input type="text" dojoType="dijit.form.TextBox" id="txt4" onblur="alert('blur')" /> //DOES NOT WORK. NOT WITH _onBlur

Change History (7)

comment:1 Changed 14 years ago by bill

Milestone: 2.0
Owner: set to Douglas Hays

Hi. That's true, we haven't exposed all the possible callbacks from the native form widgets. Partly because there are a lot of callbacks (onfocus, onblur, onselect, onchange, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup) and it would bloat our code size a lot to add them all.

In this case you can do what you did, connecting to the input node's onfocus and onblur events, or also you can connect to the *widget's* _onFocus and _onBlur events.

I suppose that onfocus and onblur are the most important events for an input widget (besides onchange), so I guess we should expose those. Marking for consideration in 2.0.

comment:2 Changed 14 years ago by alex

Milestone: 2.01.3

Milestone 2.0 deleted

comment:3 Changed 14 years ago by Douglas Hays

Milestone: 1.31.1

comment:4 Changed 14 years ago by Douglas Hays

Resolution: fixed
Status: newclosed

(In [12572]) Fixes #5327 #5907 !strict. Add onFocus and onBlur hooks to all widgets inheriting from dijit._Widget. Refactored existing _onBlur and _onFocus methods to call this.inherited. Added example user-defined onfocus/onblur methods to a sampling of widget unit tests. Renamed widget event methods like onfocus and onkeyup that will collide with user-defined event handlers.

comment:5 Changed 14 years ago by Douglas Hays

(In [12573]) References #5327 !strict. Add inline doc to onFocus and onBlur stub functions.

comment:6 Changed 14 years ago by Douglas Hays

(In [12591]) References #5327 !strict. inherited() could not find the superclass _onBlur method w/o a little naming help due to the way _onBlur was defined as an anonymous function.

comment:7 Changed 11 years ago by bill

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