
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Integrate with jQuery UI autocomplete library to provide select by autocomplete input and form helper.
Add this line to your application's Gemfile:
gem 'autocomplete_select'
And then execute:
bundle
Or install it yourself as:
gem install autocomplete_select
Make sure you required jQuery, jQuery UI and add the following to /app/assets/javascripts/application.js:
//= require autocomplete_select
Make sure you required jQuery UI css.
You have to implement a controller and action like this
class UsersController < ActionController::Base
def search
term = params[:term]
users = User.where("name LIKE ?", "%#{term}%")
render :json => users.map{ |user| {:value => user.id, :label => user.name}}
end
end
The input term
is what you type in textbox.
The output must be an array with value
and label
.
You can use autocomplete_select_tag
and autocomplete_select
.
<%= autocomplete_select_tag(name, search_path, value, autocomplete_options, html_options) %>
<%= autocomplete_select_tag(name, search_path, value, display, autocomplete_options, html_options) %>
<%= autocomplete_select_tag(:user_id, search_users_path, 1, 'username', {:minLength => 3}, {:class => 'user'}) %>
<%= autocomplete_select_tag(:user_id, search_users_path, 1, 'username') %>
<%= autocomplete_select_tag(:user_id, search_users_path) %>
or form builder
<% form_for @item do |f| %>
<%= f.autocomplete_select(method, search_path, autocomplete_options, html_options) %>
<%= f.autocomplete_select(method, search_path, display, autocomplete_options, html_options) %>
<%= f.autocomplete_select(:user_id, search_users_path, 'username', {:minLength => 3}, {:class => 'user'}) %>
<%= f.autocomplete_select(:user_id, search_users_path, 'username') %>
<%= f.autocomplete_select(:user_id, search_users_path) %>
<% end %>
The gem is available as open source under the terms of the MIT License.
The project's website is located at https://github.com/emn178/autocomplete_select
Author: Chen, Yi-Cyuan (emn178@gmail.com)
FAQs
Unknown package
We found that autocomplete_select demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.