jquery ui autocomplete - not working in IE
This code works in firefox but not IE. Any ideas? I'm using the latest jQuery-ui libraries.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>jQuery UI Autocomplete Remote datasource demo</title>
<link type="text/css" href="jquery.ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript" src="jquery.ui.core.js"></script>
<script type="text/javascript" src="jquery.ui.widget.js"></script>
<script type="text/javascript" src="jquery.ui.position.js"></script>
<script type="text/javascript" src="jquery.ui.autocomplete.js"></script>
<link type="text/css" href="demos.css" rel="stylesheet" />
<style type="text/css">
.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
.ui-autocomplete {
overflow-y: auto;
max-width: 400px;
}
/* IE 6 doesn't support max-width
* we use width instead, but this forces the menu to always be this wide
*/
* html .ui-autocomplete {
width: 400px;
}
</style>
<script type="text/javascript">
$(function() {
function log(message) {
$("<div/>").text(message).prependTo("#log");
$("#log").attr("scrollTop", 0);
}
$.ajax({
url: "links2.xml",
dataType: "xml",
success: function(xmlResponse) {
var data = $("ROW", xmlResponse).map(function() {
return {
value: $("SC_DF_FIELD_1", this).text(),
url: $("SC_DF_FIELD_2", this).text(),
support_url: $("SC_DF_FIELD_3", this).text(),
description: $("SC_DF_FIELD_4", this).text(),
contact: $("SC_DF_PERSON_LINK", this).text()
};
}).get();
$("#_results").autocomplete({
source: data,
minLength: 0
}).data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.value + "<br>" + item.url + "<br>" + item.description + "<br>" + "Support URL: " + item.support_url + "<br>" + "Contact: " + "&l开发者_高级运维t;a href=" + item.contact + ">Test</a>" + "<br />" + "</a>" )
.appendTo( ul );
}
}
})
});
</script>
Search:
The code works for me in IE. The only difference I see is that I'm using the googleapis version of jquery and jqueryui:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.js"></script>
The only other possible difference is the markup since you didn't post yours. I just have an input like this:
<input type="text" id="_results" />
精彩评论