2016-06-30 3 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에서는 아무 일도 일어나지 않습니다. 경고()를 시도하면 작동합니다. 자동 완성 기능이 수행되지 않으므로 "포커스 = true"는 전송되지 않습니다. 아무도 내가 뭘 잘못하고 있는지 알아? 내 나쁜 영어 죄송합니다

: D

+0

* "focus = true"가 전송되지 않습니다. * 무엇을 의미합니까? 그런 코드는 어디에도 보이지 않습니다. 왜 초점을 맞추기 위해 두 개의 다른 핸들러가 있습니까? –

답변

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에서 파이어 폭스의 네트워크 분석에서 게시물을 수행하지 않습니다. 그가 keydown에 들어갈 때에 만 – Hadda