我遇到了火灾错误 $("project").autocomplete 不起作用。
<script>
$(document).ready(function () {
$(function() {
$.ajax({
dataType: 'json',
async: false,
url : "<?php base_url() ?>stud_data",
success: function(data) {
projects = data.value;
}
});
$( '#project' ).autocomplete({
minLength: 1,
source: projects,
focus: function( event, ui ) {
$( '#project' ).val( ui.item.label );
return false;
},
select: function( event, ui ) {
$( '#project' ).val( ui.item.label );
$( '#project-id' ).val( ui.item.value );
$( '#project-description' ).html( ui.item.desc );
$( '#project-icon' ).attr( "src", ui.item.icon );
return false;
}
})
.data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a> <b>" + item.label +"</b>" + item.photo +"<br>" + item.desc + "</a>" )
.appendTo( ul );
};
});
});
</script>
编辑:
<script src="<? base_url() ?>/js/jqueryui/jquery-1.7.2.js" type="text/javascript"></script>
<link rel="stylesheet" href="<? base_url() ?>/js/jqueryui/themes/base/jquery.ui.autocomplete.css">
<link rel="stylesheet" href="<? base_url() ?>/js/jqueryui/themes/base/jquery.ui.base.css">
<link rel="stylesheet" href="<? base_url() ?>/js/jqueryui/themes/base/jquery.ui.theme.css">
<script src="<? base_url() ?>/js/jqueryui/ui/jquery.ui.core.js" type="text/javascript"></script>
<script src="<? base_url() ?>/js/jqueryui/ui/jquery.ui.widget.js" type="text/javascript"></script>
<script src="<? base_url() ?>/js/jqueryui/ui/jquery.ui.position.js" type="text/javascript"></script>
<script src="<? base_url() ?>/js/jqueryui/ui/jquery.ui.autocomplete.js" type="text/javascript"></script>
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/ckeditor/source/core/ckeditor.js"></script>
<script type="text/javascript" src="<? base_url() ?>/js/jquery_fancybox/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="<? base_url() ?>/js/jquery_fancybox/fancybox/jquery.fancybox-1.3.4.css" media="screen" />