#17826 closed defect (fixed)
[regression] TextBox: on("keypress", callback) never fires callback
Reported by: | bill | Owned by: | bill |
---|---|---|---|
Priority: | undecided | Milestone: | 1.9.4 |
Component: | Dijit | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
Starting in 1.9.1 (see #17154), TextBox?.on("keypress", ...) never fires.
According to Dylan, this fix actually breaks a pretty common pattern with ValidationTextBox?, which is to prevent/mask invalid input. Prior to this change, you could extend ValidationTextBox? with something like:
require([ "dojo/_base/declare", "dijit/form/ValidationTextBox", "dojo/domReady!" ], function (declare, ValidationTextBox) { function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); } var InputBox = declare([ValidationTextBox], { buildRendering: function () { this.inherited(arguments); this.on("keypress", function (event) { var value = this.get("value") + event.charOrCode; if ((/\s/).test(event.charOrCode) || !isNumber(value)) { // if value is not a number, ignore it event.preventDefault(); } }); }, validator: isNumber }); new InputBox().placeAt(document.body); });
Change History (3)
comment:1 Changed 8 years ago by
Milestone: | tbd → 1.9.4 |
---|---|
Owner: | set to bill |
Status: | new → assigned |
comment:3 Changed 8 years ago by
comment:2 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note: See
TracTickets for help on using
tickets.
In 289f96b2592e3bb23a714256ab1d48bcbfaa3bce/dijit: