问题
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
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/27637820/how-to-install-selectize-js-into-my-rails-app