sajad torkamani

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

Leave a comment

Your email address will not be published. Required fields are marked *