8

I am using jquery UI autocomplete. It works in all other browsers FF, Chrome etc except IE7. Works for higher versions of IE as well but IE7 gives the below error:

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

This is my function:

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

        }
    });

});

I tried to debug and it errors out at line : $(this).autocomplete({

Any idea? Thanks in advance

4

3 回答 3

6

看起来问题出在我的操作系统上。我已经安装了 Windows 8 消费者预览版,并且正在使用兼容 IE7 的开发工具运行 IE。它适用于 Windows 7。谢谢。

于 2012-04-12T23:14:33.920 回答
0

我的猜测是其中一个脚本没有正确加载。这发生在我身上一次,使用 jquery 和 IE 7。这是我解决问题的方法:

在 HTML 中,在所有脚本标记之前,添加以下内容:

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

当我在 jquery.min.js 的标记之前包含该行时,问题就消失了。

IE7是个挫折。

于 2012-04-12T02:11:39.577 回答
-1

我解决了更改 ui 版本。现在我使用 1.9.1.custom.min.js(之前是 jquery UI 1.8),它与 IE7 兼容。我使用 jquery v1.7.2

于 2015-11-30T14:31:00.647 回答