这是我的HTML
<input id="patient_name" name="patient" rows="5" cols="20">
这是我在html中的标题
<script type="text/javascript" src="/template/jquery.js"></script>
<script type="text/javascript" src="/template/jquery-ui.js"></script>
<script type="text/javascript" src="/template/jquery.validate.js"></script>
<script type="text/javascript" src="/template/jquery.form.js"></script>
<script type="text/javascript" src="/template/additional.methods.js"></script>
<script type="text/javascript" src="/template/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="/template/jquery-ui-sliderAccess.js"></script>
这是自动填充的脚本
$("#patient_name").autocomplete({
minLength: 0,
source:window.peerjson,
focus: function(event, ui) {
$( "#patient_name" ).val(ui.item.firstname);
return false;
},
select: function(event, ui) {
$( "#patient_name" ).val(ui.item.firstname+" "+ui.item.lastname); //ui.item is your object from the array
return false;
}
}).data( "ui-autocomplete" )._renderItem = function(ul, item) {
console.log(item);
return $( "<li></li>" )
.append( "<a>" + item.firstname + " " + item.lastname + "</a>")
.appendTo( ul );
};
运行此内容并键入内容后,它会在chrome中显示错误
Uncaught TypeError: Property 'source' of object [object Object] is not a function jquery-ui.js:6
t.widget._search jquery-ui.js:6
e.isFunction.l.(anonymous function) jquery-ui.js:6
t.widget.search jquery-ui.js:6
e.isFunction.l.(anonymous function) jquery-ui.js:6
(anonymous function) jquery-ui.js:6
i
值在json中。但不知怎的,它没有出现。