DOM issue with a click triggering a focus event on another input

  • I have <input type=text>with an event handlerfocusout
  • I have a <button>click event handler

Focusout checks the format in the input field. This is done by checking the input value for a regular expression. If it does not work, it displays a message (a divfade-in and -out after a while) and reassigns my input by calling

window.setTimout(function() { $(this).focus(); }, 10);

since I cannot reorient in the event handler focusout. The event focusoutalso cannot be canceled. Just FYI.

Click , collects data from input elements and sends it using Ajax.

Problem

When the user TABsgoes through the form, everything is in order. When a certain input window does not check formatting, it immediately reorients after being clicked by the user TAB.

But when the user does not use TAB, but instead clicks on each individual input field, everything works fine until he clicks on the button button. focusouttriggers and sets a timeout for reorientation. Since the timeout is so short that occurs after that, then the event clickfires and issues an Ajax request.

Question

jQuery, . .live() focusout , .

, , . .

, ?

, document.activeElement, Chrome. FF IE , this , Chrome , BODY , click button.

http://jsfiddle.net/Anp4b/1/ . Chrome .

+5
2

...

: http://jsfiddle.net/Anp4b/4/


, :

, ?

, , , click. , , . .

, : .

- - , .

+3

, .focusout .blur?

- , . , . .

, , , , .

1) :

var clickHandler = function(e){ /** submit form or whatever you want to do**/ };
$("button").click(clickHandler);

2) , :

$("button").unbind("click", clickHandler).one("click", function(){ button.click(clickHandler); return false;});

.

0

All Articles