2012-04-12 116 views
8

我正在使用jQuery UI自動完成。它適用於除IE7以外的所有其他瀏覽器FF,Chrome等。適用於更高版本的IE很好,但IE7給出了以下錯誤:JQuery UI自動完成IE 7問題

SCRIPT3: Member not found. 
jquery.min.js, line 2 character 30636 

這是我的函數:

$('input.autocomplete').each(function() { 
    var $input = $(this); 

    // Set-up the autocomplete widget. 
    var serverUrl = $input.data('url'); 

$(this).autocomplete({ 
    source: function(request, response) { 

    var countrySelect = $("#countrySelect").val(); 

if($input.attr('id') == 'searchJobPostalCode'){ 

    countrySelect = $("#searchJobCountrySelect").val(); 

    }else if($input.attr('id') == 'searchPeoplePostalCode'){ 

    countrySelect = $("#searchUserCountrySelect").val(); 

    } 
    $.ajax({ 
       url: serverUrl, 
       dataType: "json", 
       data: { 
        term: request.term, 
        countrySelect: countrySelect 
       }, 
       success: function(data) { 
         $input.removeClass("ui-autocomplete-loading"); 
         response($.map(data, function(item) { 
         if(typeof item.companyName != 'undefined'){ 
          return { 
           label: item.companyName, 
           value: item.companyName, 
           id: item.companyID 
          } 
        } 

         if(typeof item.locationId != 'undefined'){ 
          return { 
           label: item.postalCode +','+item.placeName+','+item.adminName1+','+item.countryCode, 
           value: item.postalCode +','+item.placeName+','+item.adminName1+','+item.countryCode, 
           postalCode: item.postalCode, 
           city: item.placeName, 
           state: item.adminName1, 
           country: item.countryCode 
          } 
        } 


         //to show user alias autocomplete on compose message 
         if(typeof item.userAlias != 'undefined'){ 
            var label1 = item.userAlias; 
            if(typeof item.city != 'undefined'){ 
             label1 = label1+','+item.city; 
            } 
            if(typeof item.state != 'undefined'){ 
             label1 = label1+','+item.state; 
            } 
            if(typeof item.country != 'undefined'){ 
             label1 = label1+','+item.country; 
            } 

          return { 
           label: item.userAlias, 
           userAlias: item.userAlias 
          } 
        } 

        })); 
       } 
      }); 
     }, 
     minLength: 3,cacheLength:0,keyDelay:900, 
     select: function(event, ui) { 

     $("#companyId").val(ui.item.id); 

     if(typeof ui.item.userAlias != 'undefined'){ 
      $(".toUser").val(ui.item.userAlias); 
     } 

     if(typeof ui.item.postalCode != 'undefined'){ 
       $("#postalCode").val(ui.item.postalCode); 
       $("#city").val(ui.item.city); 
       $("#state").val(ui.item.state); 
       $("#country").val(ui.item.country); 


        if($input.attr('id') == 'searchJobPostalCode'){ 

           $("#searchPostalCodeJobsSearch").val(ui.item.postalCode); 
           $("#searchCityJobsSearch").val(ui.item.city); 
           $("#searchStateJobsSearch").val(ui.item.state); 
           $("#searchCountryJobsSearch").val(ui.item.country); 

        }else if($input.attr('id') == 'searchPeoplePostalCode'){ 

           $("#searchPostalCodePeople").val(ui.item.postalCode); 
           $("#searchCityPeople").val(ui.item.city); 
           $("#searchStatePeople").val(ui.item.state); 
           $("#searchCountryPeople").val(ui.item.country); 

        } 


     } 
     }, 
       change: function(event, ui) { 
       if($(this).attr('id') !='companyName'){ 
         if (ui.item == null) { 
           valid = false; 
          }else{ 
           valid = true; 
          } 
          if (!valid) { 
           // remove invalid value, as it didn't match anything 
           $(this).val(""); 
           select.val(""); 
           input.data("autocomplete").term = ""; 
           return false; 
          } 
         } 
     }, 
     open: function() { 
      $(this).removeClass("ui-corner-all").addClass("ui-corner-top"); 
     }, 
     close: function() { 
      $(this).removeClass("ui-corner-top").addClass("ui-corner-all"); 
      $(this).removeClass("ui-autocomplete-loading"); 

     } 
    }); 

}); 

我試圖調試,並在線路就出現了錯誤:$(this).autocomplete({

任何想法?在此先感謝

+0

嘗試將'input'類重命名爲'autocomplete'以外的內容。也許'input.ac'什麼的。而且,它看起來像'$(this).autocomplete({'可能是'$ input.autocomplete({' – 2012-04-12 20:47:14

+0

謝謝。這並沒有解決它。 – 2012-04-12 23:13:07

回答

6

看起來問題是與我的操作系統。我安裝了Windows 8消費者預覽版,並且在IE7兼容性中使用開發工具運行IE。它在Windows 7中工作。謝謝。

+0

謝謝你。 – 2012-07-28 20:29:22

+0

似乎在Win7上運行IE7模式的IE10是一樣的(Win8有捆綁IE10的權利?)但是,它對在VirtualPC上運行的真正的IE7運行良好。 – LinusR 2013-04-03 20:18:49

0

我的猜測是其中一個腳本加載不正確。這發生在我身上一次,jQuery和IE 7.下面是如何解決這個問題:

在HTML,之前的所有腳本標記的,補充一點:

<script type="text/javascript"></script><!--this is here because of an IE bug--> 

當我包括在這之前線我的標籤爲jquery.min.js,問題就消失了。

IE7是一個沮喪。

+0

試過這個,但沒有運氣。 – 2012-04-12 23:13:18

-1

我解決了更改用戶界面版本。現在我使用1.9.1.custom.min.js(之前是jQuery UI 1.8),它與IE7兼容。我使用jquery v1.7.2