我正在尝试使用 jqueryUI 自动完成功能,其中可用的标签将从后端源中获取。这是我的代码。
代码
<div class="span4 pull-right" id="search">
Search : <input type="text" placeholder="Search">
</div>
js代码
<script>
$(function() {
$( "#search" ).autocomplete({
source: "/dashboard/search"
});
});
</script>
** django views.py **
def search(request):
availableTags = ["ActionScript","AppleScript","Asp","BASIC","C","C++","Clojure","COBOL","ColdFusion","Erlang"];
ctx = {"availableTags":availableTags}
return HttpResponse(availableTags) #returns the set of values(checked with firebug while debugging) but autocomplete doesnot works.
#return render(request, 'dashboard/dashboard.html', ctx) // returns nothing.
仪表板 urls.py
urlpatterns = patterns('modules.energy.dashboard.views',
url(r'^$','dashboard',name='cilantro_dashboard'),
url(r'search','search',name='cilantro_search'),
)
主要网址.py
urlpatterns = patterns('',
url(r'^dashboard/', include('modules.energy.dashboard.urls')),
)
这是我在使用 firebug 调试时收到的响应。
ActionScriptAppleScriptAspBASICCC++ClojureCOBOLColdFusionErlang
我availabletags
的被退回,但自动完成仍然不起作用。我哪里错了?