2016-06-30 8 views
-1

私は以下のコードを持っています。JQuery .autocomplete focus doesnt work

function halle(row, settings, row_element) { 
    $('input', row).autocomplete({ 
     minLength: "0", 
     source: "../../shared/hallensuche.aspx", 
     select: function (e, ui) { 
      $(this).val(ui.item.label); 
      //update hallennr 
      var aPos = oTableAnwurfzeiten.fnGetPosition(row_element); 
      oTableAnwurfzeiten.fnUpdate(ui.item.value, aPos[0], 11); 
      isHalleChanged = true; 
      $(this).focus().select(); 
      return false; 
     }, 
     search: function (e, ui) { 
     }, 
     focus: function (e, ui) { 
      $(this).val(ui.item.label); 
      return false; 
     } 
    }).focus(function (e, ui) { 
     $(this).autocomplete("option", "source", "../../shared/hallensuche.aspx?focus=true"); 
     $(this).trigger('keydown.autocomplete'); 
     $(this).select(); 
     return false; 
    }).keydown(function (e, ui) { 
     $(this).autocomplete("option", "source", "../../shared/hallensuche.aspx?focus=false" + $('input', row).val()); 
    }); 
} 

入力に何か書き込むと、keydownコマンドが実行されます。 .focusでは何も起こりません。私がアラートを試みると、それは機能します。オートコンプリートは実行されないので、 "focus = true"は送信されません。誰かが私が間違っていることを知っていますか?私の悪い英語のため申し訳ありません

:D

+0

* "focus = true"は送信されません*?私はそのようなコードはどこにも見ません。フォーカスのために2つの異なるハンドラがあるのはなぜですか? –

答えて

0

代わりに焦点focusinを使用してみてください。更新されたコードは次のようになります。

$('input', row).autocomplete({ 
     minLength: "0", 
     source: "../../shared/hallensuche.aspx", 
     select: function (e, ui) { 

     }, 
     search: function (e, ui) { 
     }, 
     focus: function (e, ui) { 
      $(this).val(ui.item.label); 
      return false; 
     } 
    }).on("focusin",function (e, ui) { 
     console.log("trigger here"); 
    }).keydown(function (e, ui) { 

    }); 

デモhereを参照してください。

+0

変更なし。しかし、私はconsole.logを取得しますが、オートコンプリートは実行されません。 XHRの下でのfirefoxのネットワーク解析ではポストを実行しません。彼がキーダウンに入るときだけ – Hadda

関連する問題