Ruby on Rails unobtrusive scripting adapter
This unobtrusive scripting support file is developed for the Ruby on Rails framework, but is not strictly tied to any specific backend. You can drop this into any application to:
- force confirmation dialogs for various actions;
- make non-GET requests from hyperlinks;
- make forms or hyperlinks submit data asynchronously with Ajax;
- have submit buttons become automatically disabled on form submit to prevent double-clicking.
These features are achieved by adding certain
data attributes to your HTML markup. In Rails, they are added by the framework's template helpers.
Note that the
data attributes this library adds are a feature of HTML5. If you're not targeting HTML5, these attributes may make your HTML to fail validation. However, this shouldn't create any issues for web browsers or other user agents.
npm install rails-ujs --save
yarn add rails-ujs
.yarnclean does not include
assets if you use yarn autoclean.
In a conventional Rails application that uses the asset pipeline, require
rails-ujs in your
//= require rails-ujs
import Rails from 'rails-ujs'; Rails.start()
How to run tests
bundle exec rake ujs:server first, and then run the web tests by visiting http://localhost:4567 in your browser.
rails-ujs is released under the MIT License.