-
Notifications
You must be signed in to change notification settings - Fork 10
Home
Welcome to the auto_complete wiki!
You’ll likely need to add something to your routes.rb file. If you’re doing
class UsersController < ApplicationController
auto_complete_for :user, :login
You’d add this to your routes
map.resources :users,
:collection => {
:auto_complete_for_user_login => :get
}
Note the use of :get, not :post. Using :post will cause you to get an InvalidAuthenticityToken error. Once you specify get in your routes, ensure that your forms also make get request by specifying the method in the 4th view method parameter.
<%= text_field_with_auto_complete :user, :login, {}, :method => :get %>
Use with ModalBox
You’ll need to add a z-index to your css, like so:
div.auto_complete {
width: 350px;
background: #fff;
z-index:10005 !important;
}
Note that the css is in /vendor/plugins/auto_complete/lib/auto_complete_macros_helper.rb but can be ignored so you can override it in your CSS by passing :skip_style => true like so:
text_field_with_auto_complete :user, :login, :skip_style => true
When calling Modalbox.show you’ll need to use the afterLoad option to get things working. Here’s a javascript example:
Modalbox.show($('user_lookup'), {title: 'User Look Up' , width: 450,
afterLoad: function () {
var user_login_auto_completer = new Ajax.Autocompleter('user_login', 'user_login_auto_complete', '/users/auto_complete_for_user_login', {});
}};