当我将 jquery ui 自动完成版本 1.8.5 与 jquery mobile alpha 2 一起使用时。单击自动完成列表中的项目时出现错误:
$this.attr("href") 未定义。
有谁知道它的任何修复?
编辑:
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.custom.css">
<link rel="stylesheet" type="text/css" href="css/autocomplete.css">
</head>
<body>
<div id="formWrap">
<form id="messageForm" action="#">
<fieldset>
<label id="toLabel">select:</label>
<div id="friends" class="ui-helper-clearfix">
<input id="to" type="text">
</div>
</fieldset>
</form>
</div>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.0a2.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.custom.min.js"></script>
<script type="text/javascript">
$(function(){
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
//attach autocomplete
$("#to").autocomplete({
source:availableTags
,
//define select handler
select: function(e, ui) {
var contact = ui.item.value;
createSpan(contact);
$("#to").val("").css("top", 2);
return false;
}
});
});
function createSpan(contact){
//create formatted friend
span = $("<span>").text(contact)
//add contact to contact div
span.insertBefore("#to");
}
</script>
</body>
</html>