Setup rails-ujs in Rails
11 March 2022 (Updated 11 March 2022)
On this page
What is Rails UJS?
Rails UJS is a JavaScript library that helps you implement common functionality such as:
- Show confirmation dialogs for various actions (e.g., deleting a record)
- Make non-GET requests from hyperlinks.
- Have submit buttons become automatically disabled to prevent double-clicking.
- Make Ajax requests on clicking hyperlinks or submitting forms.
Setup
Install library:
npm install @rails/ujs --save
Initialize:
import Rails from '@rails/ujs'
Rails.start()
Sources
Tagged:
Rails tooling
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment