2012-04-12 17 views
8

jquery UIオートコンプリートを使用しています。他のすべてのブラウザFF、IE7を除くChromeなどで動作します。私はラインでデバッグし、それエラー出しようとしたJquery UIオートコンプリートIE 7の問題

$('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"); 

     } 
    }); 

}); 

:だけでなくIEの以降のバージョンで動作しますが、IE7は以下のエラーを与える:

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

これは私の関数である$(this).autocomplete({

何か案が?事前に感謝します

+0

'input'クラスの名前を' autocomplete'以外に変更してみてください。たぶん 'input.ac'か何か。そして、それは '$(this)).autocomplete({' $ input.autocomplete({' –

+0

ありがとう)これは解決しませんでした。 –

答えて

6

OSに問題があるようです。私はWindows 8のコンシューマプレビューをインストールし、IE7と互換性のある開発ツールを使用してIEを実行していました。それは窓7で動作します。ありがとう。

+0

私は –

+0

Win7でIE7モードで動作しているIE10と同じに見えます(Win8にはIE10がバンドルされていますか?)しかし、VirtualPC上で動作するIE7ではうまく動作します。 – LinusR

0

私の推測では、スクリプトの1つが正しく読み込まれていないということです。これはjQueryを使って、一度私に起こったとIE 7は、ここで私は問題を解決方法は次のとおりです。

HTMLでは、あなたのスクリプトタグのすべてが、この追加する前に:私は前にその行を含める場合は

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

をjquery.min.jsのための私のタグ、問題は遠ざかった。

IE7は欲求不満です。

+0

これはお試しですが運がありませんでした –

-1

私はchange uiバージョンで解決しました。今私は1.9.1.custom.min.jsを使用しています(以前はjquery UI 1.8でした)、IE7との互換性があります。私はjquery v1.7.2を使用します。

関連する問題