Jquery的自动完成功能对我不起作用,但我没有收到任何错误。我已经在我网站上的空白页面上测试了这个代码并且它已经起作用,这使我相信下面的内容是冲突的。
使用Javascript:
$("#search").autocomplete({
source: function(request, response) {
$.ajax({
url: "/candidates/search.json?name=" + request.term,
dataType: "json",
data: {
term: request.term
},
success: function(data) {
alert();
response(data.data.map(function(value) {
return {
'label': value.FormattedName,
'id': value.id,
'value': value.FormattedName
};
}));
}
});
},
minLength: 1,
select: function(event, ui) {
window.location.href = "/candidate/" + ui.item.id;
}
});
Jquery包含
<%@include file="body-scripts-start.jspf" %>
<script src="assets/vendor/jquery-ui-touch-punch/jquery.ui.touch-punch.js"></script>
<script src="assets/vendor/jquery-appear/jquery.appear.js"></script>
<script src="assets/vendor/bootstrap-multiselect/bootstrap-multiselect.js"></script>
<script src="assets/vendor/jquery-easypiechart/jquery.easypiechart.js"></script>
<script src="assets/vendor/flot/jquery.flot.js"></script>
<script src="assets/vendor/flot-tooltip/jquery.flot.tooltip.js"></script>
<script src="assets/vendor/flot/jquery.flot.pie.js"></script>
<script src="assets/vendor/flot/jquery.flot.categories.js"></script>
<script src="assets/vendor/flot/jquery.flot.resize.js"></script>
<script src="assets/vendor/jquery-sparkline/jquery.sparkline.js"></script>
<script src="assets/vendor/raphael/raphael.js"></script>
<script src="assets/vendor/morris/morris.js"></script>
<script src="assets/vendor/gauge/gauge.js"></script>
<script src="assets/vendor/snap-svg/snap.svg.js"></script>
<script src="assets/vendor/liquid-meter/liquid.meter.js"></script>
<script src="/assets/javascripts/dashboard.js"></script>
<script src="/assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
<script src="/assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>
body-scripts-start.jspf的内容
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" rel="Stylesheet"></link>
<script src="/assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
<script src="/assets/vendor/bootstrap/js/bootstrap.js"></script>
<script src="/assets/vendor/nanoscroller/nanoscroller.js"></script>
<script src="/assets/vendor/magnific-popup/magnific-popup.js"></script>
<script src="/assets/vendor/jquery-placeholder/jquery.placeholder.js"></script>
<script src="/assets/vendor/pnotify/pnotify.custom.js"></script>
<script src="/assets/vendor/handlebars/handlebars-v2.0.0.js"></script>
<script src="/assets/vendor/momentjs/moment.min.js"></script>
<sec:authorize access="isAuthenticated()">
<script src="/assets/javascripts/common.js"></script>
<script src="/assets/vendor/sockjs/sockjs-0.3.4.min.js"></script>
<script src="/assets/vendor/stompjs/stomp.min.js"></script>
<script src="/assets/javascripts/notifications.js"></script>
</sec:authorize>
答案 0 :(得分:0)
对于遇到类似问题的其他人,我将两个jQuery UI文件包含在单独的文件中,这两个文件都被加载到同一个文件中。这超越了我需要的最新方法。