我正在尝试实现自动完成功能。我浏览了https://github.com/crowdint/rails3-jquery-autocomplete但我不得不错过一些东西,因为自动完成字段根本不起作用。
当我尝试使用自动完成字段时,没有任何反应。Chrome JS 控制台显示以下错误:
Uncaught TypeError: Object [object Object] has no method 'autocomplete'
控制器:
class GamesController < ApplicationController
autocomplete :game, :title
路线.rb:
get "games/autocomplete_game_title" => "games#autocomplete_game_title", :controller => 'games', :action => "autocomplete_game_title", :via => :get, :as => "autogames"
查看(游戏/编辑):
<% form_for Game.new, :url => { :controller => "games", :action => "edit" } do |f| %>
<%= f.error_messages %>
<%= f.autocomplete_field :title, autogames_path %>
<%= f.submit "Edit" %>
<% end %>
布局标题:
<link href="/stylesheets/admin.css?1300378198" media="screen" rel="stylesheet" type="text/css" />
<script src="/javascripts/jquery.js?1335792905" type="text/javascript"></script>
<script src="/javascripts/jquery_ujs.js?1335792905" type="text/javascript"></script>
<script src="/javascripts/application.js?1335809045" type="text/javascript"></script>
<script src="/javascripts/autocomplete-rails.js?1336304504" type="text/javascript"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/smoothness/jquery-ui.css" media="screen" rel="stylesheet" type="text/css" />
我完全糊涂了,我检查了几乎所有的组合。有什么建议可能是错的吗?