Joe Morano
Joe Morano

Reputation: 1895

How to install Selectize.js into my Rails app?

I downloaded Selectize.js and I'm trying to install it into my Rails 4 app, but there are so many files and I'm so confused. Can anyone who has successfully installed Selectize into their app help me out with this? I'm trying to achieve an autosuggest input bar into which the user can input no more than 6 items from the database.

Here are the contents of my download (version 0.11.0): Sorry about the immense number of documents, but that's exactly why I'm so confused.

-brianreavis-selectize.js-v0.11.0-0-gf293d8b (folder)
  -brianreavis-selectize.js-f293d8b (folder)
    -dist (folder)
      -css (folder)
        -selectize.css
        -selectize.bootstrap2.css
        -selectize.boostrap3.css
        -selectize.default
        -selectize.legacy
      -js (folder)
        -standalone (folder)
          -selectize.js
          -selectize.min.js
        -selectize.js
        -selectize.min.js
      -less (folder)
        -plugins (folder)
          -drag_drop.less
          -dropdown_header.less
          -optgroup_columns.less
          -remove_button.less
        -selectize.bootstrap2.less
        -selectize.bootstrap3.less
        -selectize.default.less
        -selectize.legacy.less
        -selectize.less
    -docs (folder)
      -api.md
      -events.md
      -plugins.md
      -usage.md
    -src (folder)
      -contrib (folder)
        -highlight.js
        -microevent.js
      -less (folder)
        -.wrapper.css
        -selectize.bootstrap2.less
        -selectize.bootstrap2.less
        -selectize.default.less
        -selectize.legacy.less
        -selectize.less
      -plugins (folder)
        -drag_drop (folder)
          -plugin.js
          -plugin.less
        -drop_down_header (folder)
           -plugin.js
           -plugin.less
        -optgroup_columns (folder)
           -plugin.js
           -plugin.less
        -remove_button (folder)
           -plugin.js
           -plugin.less
        -restore_on_backspace (folder)
           -plugin.js
      -.wrapper.js
      -constants.js
      -defaults.js
      -selectize.js
      -selectize.jquery.js
      -utils.js
    -test (folder)
      -vendor (folder)
        -chai.js
        -mocha.css
        -mocha.js
        -syn.js
      -api.js
      -events.js
      -events_dom.js
      -index (Chrome Html Document)
      -interaction.js
      -setup.js
      -xss.js
    -.gitignore
    -.travis.yml
    -bower.json
    -Gruntfile.js
    -LICENSE
    -Makefile
    -package.json
    -selectize.jquery.json
    -testem.json

Upvotes: 1

Views: 1802

Answers (2)

I am PK
I am PK

Reputation: 6764

First thing you need to do is install the gem file. Add this line to your gemfile

 gem "selectize-rails"

now run the bundle from your commandline.

Next you need to tell your application to use selectize to do that add the below line to your application.js file

 //= require selectize

That was it.

Upvotes: 2

henggana
henggana

Reputation: 157

Best way to include javascripts plugins to your rails app is to use gems, if it exist. Thankfully, there is one for selectize, selectize-rails.

Upvotes: 1

Related Questions