문제

ASP.NET WebForm에 jQuery autocomplete 필드가 있으며 지금까지 모든 것이 잘 작동했습니다. 또한 autopostback으로 OnSelectedIndexChanged를 발사 할 필요가 있다는 드롭 다운 목록이 있습니다.

AutoPostback을 수행하도록 코드를 변경하면 jQuery AutoComplete가있는 텍스트 필드가 다시 비워집니다. 그러나 페이지 소스를 보면 텍스트가 텍스트 필드에 있습니다. 이제 양식을 게시하면 페이지가 빈 필드를 다시 전송합니다. 내 Google-Fu는이 문제에 대해 약합니다.

AutopostBack에서 AutoComplete 필드가 비워지는 데 이와 같은 문제가있는 사람이 있습니까?

실제로 필요한 경우 코드를 게시 할 수 있지만 회사 정책 때문에 코드를 많이 소독해야합니다.

도움이 되었습니까?

해결책

자동 완성 필드는 어떻게 초기화됩니까? 서버에서 또는 autocomplete jquery 플러그인에 의해 페이지로드에서 빈 문자열로 설정되어 있습니까?

플러그인의 소스 코드가 텍스트 상자를 document에서 비어있는 문자열로 설정하는 경우 다음을 시도하십시오.

// Store current textbox value in a var
var temp = $('#mytextbox').val();

// Initialize the autocomplete plugin (winging it on the syntax)
$('#mytextbox').autocomplete();

// Reset the value of the textbox.
$('#mytextbox').val(temp);

다른 팁

jQuery AutoComplete 플러그인 1.1, * 개정 : $ id : jQuery.autocomplete.js 15 2009-08-22 10 : 30 : 27Z Joern.zaefferer $

옵션에서 "autopostbackselection : false"를 추가하십시오 :

$.Autocompleter.defaults = {
    inputClass: "ac_input",
    resultsClass: "ac_results",
    loadingClass: "ac_loading",
    minChars: 1,
    delay: 400,
    autoPostBackSelection: false,
    ...

다음, "selectCurrent () 함수의 끝에서 return true; return true; 직전에 이것을 추가하십시오.

if (options.autoPostBackSelection == true) {
        __doPostBack($input.id, "");
      }

예시:

함수 selectCurrent () {... if (Options.AutoPostBackSelection == true) {__dopostback ($ input.id, ""); } true를 반환합니다. }

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top