0
我得到了fire bug $(「project」)。autocomplete不是函數。當我運行這個頁面時,我在firebug中看到錯誤
<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" />
是否包含在您的網頁插件? – tradyblix
請確保您包含jquery ui javascript文件http://jqueryui.com/download – Kris
我已包含所有插件,請參閱我的編輯。 – Hardik