1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/app/assets/javascripts
Elliot Winkler f01f2e648d rails-ujs: Update README
Make various wording tweaks to cater to users who are viewing the README
on NPM. Notably, don't highlight Yarn specifically in the installation
instructions -- even though this is the preferred tool of choice
especially in the Ruby community, some people still use NPM (and,
really, ES2015+ syntax has nothing to do with NPM or Yarn).
2017-10-02 16:51:59 -05:00
..
rails-ujs Merge pull request #29151 from onemanstartup/jquery_slim_fix 2017-05-29 13:37:53 -05:00
MIT-LICENSE Move rails-ujs README and LICENCE to actionview 2017-02-22 13:49:27 -05:00
rails-ujs.coffee Reorganize rails-ujs files 2017-03-30 14:41:17 -04:00
README.md rails-ujs: Update README 2017-10-02 16:51:59 -05:00

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.

Optional prerequisites

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.

Installation

NPM

npm install rails-ujs --save

Yarn

yarn add rails-ujs

Usage

Asset pipeline

In a conventional Rails application that uses the asset pipeline, require rails-ujs in your application.js manifest:

//= require rails-ujs

ES2015+

If you're using the Webpacker gem or some other JavaScript bundler, add the following to your main JS file:

import Rails from 'rails-ujs';
Rails.start()

How to run tests

Run bundle exec rake ujs:server first, and then run the web tests by visiting http://localhost:4567 in your browser.

License

rails-ujs is released under the MIT License.