Jquery ui Jquery UI自动完成IE 7问题
我正在使用jQueryUI自动完成。它适用于除IE7之外的所有其他浏览器FF、Chrome等。也适用于更高版本的IE,但IE7给出了以下错误:Jquery ui Jquery UI自动完成IE 7问题,jquery-ui,Jquery Ui,我正在使用jQueryUI自动完成。它适用于除IE7之外的所有其他浏览器FF、Chrome等。也适用于更高版本的IE,但IE7给出了以下错误: SCRIPT3: Member not found. jquery.min.js, line 2 character 30636 这是我的职责: $('input.autocomplete').each( function() { var $input = $(this); // Set-up the autocomplete wi
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({
有什么想法吗?提前谢谢我猜其中一个脚本加载不正确。我曾经遇到过这种情况,使用jquery和IE 7。以下是我解决问题的方法: 在HTML中,在所有脚本标记之前添加以下内容:
<script type="text/javascript"></script><!--this is here because of an IE bug-->
当我在jquery.min.js的标记前面包含这一行时,问题就消失了
IE7令人沮丧。看来问题出在我的操作系统上。我安装了Windows 8 consumer preview,并在IE7兼容中使用开发工具运行IE。它在Windows 7中工作。谢谢。我通过更改ui版本解决了问题。现在我使用1.9.1.custom.min.js(以前是jquery ui 1.8)它与IE7兼容。我使用jquery v1.7.2尝试将
input
类重命名为autocomplete
以外的其他类。可能是input.ac
或其他什么。而且,它看起来像$(这个)。autocomplete({
可能是$input.autocomplete>)({
谢谢。这并没有解决问题。谢谢。我正在努力。在Win7上以IE7模式运行的IE10似乎也一样。(Win8是否捆绑了IE10?)不过,它对于在VirtualPC上运行的真正IE7来说效果很好。