jquerymobile conflict with autocomplete : $this.attr("href") is undefined
- by sweets-BlingBling
When I use jquery ui autocomplete version 1.8.5 with jquery mobile alpha 2.
I get an error when I click an item from the autocomplete list:
$this.attr("href") is undefined.
Does anyone know any fix for it?
EDITED:
<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>