bootstrap-findahead-rails
A search component for Twitter Bootstrap
Installation
Add this line to your application's Gemfile:
group :assets do
gem 'bootstrap-findahead-rails'
end
And then execute:
$ bundle install
Stylesheets Add necessary stylesheet file to app/assets/stylesheets/application.css
*= require bootstrap-findahead
Javascripts Add necessary javascript(s) files to app/assets/javascripts/application.js
//= require bootstrap-findahead
Usage
Via JavaScript
$('.findahead').typeahead()
Options
Name | Type | Default | Description |
---|---|---|---|
source | function | [] | The data source to query against. Should be a function is passed two arguments, the query value in the input field and the process callback. The function may be used synchronously by returning the data source directly or asynchronously via the process callback's single argument. |
items | number | 8 | The max number of items to display in the dropdown. |
minLength | number | 1 | The minimum character length needed before triggering autocomplete suggestions |
matcher | function | case insensitive | The method used to determine if a query matches an item. Accepts a single argument, the item against which to test the query. Access the current query with this.query. Return a boolean true if query is a match. |
sorter | function | exact match, case sensitive, case insensitive | Method used to sort autocomplete results. Accepts a single argument items and has the scope of the findahead instance. Reference the current query with this.query. |
updater | function | returns selected item | The method used to return selected item. Accepts a single argument, the item and has the scope of the findahead instance. |
highlighter | function | highlights all default matches | Method used to highlight autocomplete results. Accepts a single argument item and has the scope of the findahead instance. Should return html. |
timer | number | 0 | Time to wait before last type to execute query. In milliseconds. |
visualLoading | boolean | true | Show or hide visual loading component |
Methods
.findahead(options) Initializes an input with a findahead.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Thanks
Thanks to twitter bootstrap for typeahead.