このHTMLの場合:
<div id="SomeDiv">
   <input id="SomeInput" />
   <div id="ChildDiv"></div>
</div>
のblurイベントに割り当てられたイベントハンドラーがありSomeInputます。ぼかしイベントハンドラーは、の子のSomeDivいずれかがSomeDivまだフォーカスを持っているかどうかを確認し、フォーカスがある場合は中止します(設計による)。
問題は、blur()をSomeInput実用的に呼び出すと、SomeInputのblurイベントハンドラーが実行されますが、SomeDivまだフォーカスがあると見なされるため中止されます。
入力と親divを明示的にぼかしてみましたが、入力ハンドラーはその親をフォーカスされていると見なします。また、ウィンドウとボディの要素に焦点を合わせてぼかしてみましたが、何も起こらないようです。
、、、およびの子を同時にぼかしてSomeInput、SomeInputのイベントハンドラーを実行すると、 SomeDivがフォーカスされていると見なされないようにするにはどうすればよいですか?SomeDivSomeDiv
イベントハンドラー:
this.eBlur = function(event,eventThis) {
   console.log(this.$element.attr('id')+' has lost focus.');
   if(this.$element.has(":focus").length === 0){
      console.log('widget does not have focus');
      // do something.
   }
   else{
      console.log('something is still focused, do nothing.');
   }
}
var base = this;
this.$input.bind('blur', function(e){base.eBlur(e,this);});
次に実行するには:
console.log('about to blur');
this.$input.blur();
// The blur handler runs immediately here
console.log('blur complete');
したがって、ログには次のように表示されます。
about to blur
this.$element.attr('id')+' has lost focus.
something is still focused, do nothing.
blur complete