Skip to content

Rails asset gem for Twitters typeahead.js jquery plugin. Tracks more recent version

License

Notifications You must be signed in to change notification settings

ExamTime/twitter-typeahead-rails

 
 

Repository files navigation

ExamTime's fork of a fork of a gem for typeahead JS

Rationale

See issue for details on why we have this fork https://github.com/ExamTime/ExamTime/issues/14072

Once the other (more) offical Gems have got patches merged in we can use that again and get rid of this.

Twitter typeahead.js jquery plugin

This asset gem packages the mantained twitter typeahead.js jquery plugin for the Rails asset pipeline.

To learn more about typeahead.js read the post Twitter's engineering blog.

This gem includes the standard and minified versions of the assets.

Installation

Add this line to your application's Gemfile:

gem 'twitter-typeahead-rails' # For the original one

or

gem 'twitter-typeahead-rails', :git => "git://github.com/loop23/twitter-typeahead-rails.git"

And then execute:

$ bundle

Or install it yourself as:

$ gem install twitter-typeahead-rails

Usage

To start using the twitter typeahead.js plugin in your rails app enable it via the asset pipeline (app/assets/javascripts/application.js).

Add one of the following to your application.js manifest:

//= require twitter/typeahead

//= require twitter/typeahead.min
// Twitter typeahead example.

// instantiate the bloodhound suggestion engine
var numbers = new Bloodhound({
  datumTokenizer: Bloodhound.tokenizers.obj.whitespace('num'),
  queryTokenizer: Bloodhound.tokenizers.whitespace,
  local: [
    { num: 'one' },
    { num: 'two' },
    { num: 'three' },
    { num: 'four' },
    { num: 'five' },
    { num: 'six' },
    { num: 'seven' },
    { num: 'eight' },
    { num: 'nine' },
    { num: 'ten' }
  ]
});

// initialize the bloodhound suggestion engine
numbers.initialize();

// instantiate the typeahead UI
$('.example-numbers .typeahead').typeahead(null, {
  displayKey: 'num',
  source: numbers.ttAdapter()
});

Currently this version tracks version v0.11.1.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Rails asset gem for Twitters typeahead.js jquery plugin. Tracks more recent version

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%