、私はそれはそう、その後もそれを止めるために、DIVのクリックイベントにアタッチしe.preventDefault()
、身体のクリックイベントにアタッチ提案することができる唯一のこと。あるいは、各フォーム要素のfocus/blurイベントに.delay
でバインドすることもできます。 1つの要素からフォーカスを失って別の要素にフォーカスしていない場合は、フォームを送信します。
EDIT
これはあなたが探しているものであるかどうかを確認してください:
Javascriptを:
var queueSubmit;
$('#sample input').each(function(i,e){
$(this).bind('focus',function(){
clearTimeout(queueSubmit);
});
$(this).bind('blur',function(){
queueSubmit = setTimeout(function(){ $('#sample').submit(); }, 1000);
});
});
$('#sample').bind('submit',function(){
clearTimeout(queueSubmit);
alert('Pseudo-Submitted!');
return false;
});
サンプルHTML
<div id="main">
<p> </p>
<div id="main-form">
<form id="sample" method="POST" target="">
<fieldset>
<legend>My Sample Form</legend>
First Name: <input type="text" id="first_name" /><br />
Last Name: <input type="text" id="last_name" /><br />
Telephone: <input type="text" id="telephone" /><br />
<input type="submit" value="Submit" />
</fieldset>
</form>
</div>
<p> </p>
</div>
イベントターゲット(
event.target
)は
#formDiv
の子孫要素であるならば、私は体にクリックハンドラを入れて見てこれを行うだろう
Working Example Here
ユーザーが外をクリックしていない場合はどうdiv? – RobertPitt
私の更新された回答をご覧ください。 –