Login Register

Problem - Ignoring a keypress from an alert dialog (in Firefox)???

Hello, everybody:

I've got a little application that checks the length of a text field, and if it's 5 characters long, it fires an xhrGet to get data to populate other fields in the form.

I'm using dojo.connect to add the function that responds to onKeyUp to the text field.

If the xhrGet doesn't return any data, the user is warned, and the user must enter data into the remaining fields by hand.

I'm using an alert() to let the user know that they have to enter data themselves.

The problem is this:
If the user presses the enter key to dismiss the alert, that's interpreted as another onKeyUp from the text field, and the field's onKeyUp fires again, causing the alert to appear again -- entering an endless loop, until the mouse is used to click the alert's Ok button.

Firebug shows that the alert dismissal event is identical to one that was fired from the text area, so there's no way that I can see to stop this behavior.

IE 6 seems to work fine, with no extra firing of events.

Any ideas?

Thanks!
Greg

focus problem

The problem is that the focus is never changed from the text box even though an alert is spawned.

You have a few options:
* change the focus programmatically before the alert is called (via focus())
* inside your listener function, check to see if it's an enter key and the length is greter than 5 and then just ignore it
* don't use an alert to notify the user (use a error div or DailogBox).

Personally, I feel that using an alert is a bad UI decision and would opt for #3.

Thanks, Seth

Seth:

I was actually using the alert as a placeholder until the clients decide what they want.

I'm leaning toward DialogBox myself, especially since I can add a checkbox to it that will allow the user to suppress the DialogBox if they don't want to see it again.

Is this a firefox issue or a dojo issue?

Thanks again,
Greg

Seems like browser issue

My gut instinct is to say it's a browser issue and not a dojo issue since dojo is just listening to events from the node and the browser is sending them.

Not sure if it's an IE or FF issue though as I don't know if there's a part of the spec on how a browser should behave WRT focus when a alert is spawned.

Interesting problem....