I have a bunch of NumberTextBoxes which I created programmatically. Now, I have to compute some values on keypress so I call a function for that... Looks something like this:
...
<head>
...
function setNumTextBox() {
...
var val = {
name: "mytextbox",
onKeyPress: keyPressFxn
}
new dijit.form.NumberTextBox(val, "mytextbox");
}
function keyPressFxn(evt) {
// do the processing here
}
...
Now, my problem is this. The user types, say, "12". When the user types in "1", dijit.byId("mytextbox").attr("value") is "". When the user types in the "2", the value is now "1". In short, the value (I've also tried the "displayedValue" attribute) that I get in the function is not the latest.
I tried to use "intermediateChanges: true" but it doesn't work for the text box for this case. Now, I went ahead and used the "onChange" event instead of "onKeyPress". I get the correct values but... I don't know what called the onChange event.
Questions:
If I am to use the "onKeyPress" event, how do I get the latest value? Meaning, if I type in "123", I'll get "123" when I access the field's value/displayedValue.
If I use "onChange", how do I get the id of the element that fired the onChange event? (it's not as simple as evt.target.id right? Tried that one and it didn't work)
Or, do I have to use a combination of the 2? Like, get the id of the caller via onKeyPress then get the updated value that the user typed via onChange?
Thanks!