Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rails/ujs

Package Overview
Dependencies
Maintainers
8
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rails/ujs

Ruby on Rails unobtrusive scripting adapter

  • 7.1.402
  • Source
  • npm
  • Socket score

Version published
Maintainers
8
Created

What is @rails/ujs?

@rails/ujs is a JavaScript library that provides Unobtrusive JavaScript (UJS) helpers for Ruby on Rails applications. It helps in handling common JavaScript behaviors in a Rails application, such as handling AJAX requests, form submissions, and link clicks, without writing custom JavaScript code.

What are @rails/ujs's main functionalities?

Handling AJAX Requests

This feature allows you to handle AJAX requests by simply adding `data-remote="true"` to your HTML elements. The @rails/ujs library will automatically handle the AJAX request and response.


// HTML
<a href="/some_path" data-remote="true">Click me</a>

// JavaScript
import Rails from '@rails/ujs';
Rails.start();

// This will automatically handle the AJAX request for the link with data-remote="true"

Form Submission

This feature allows you to submit forms via AJAX by adding `data-remote="true"` to your form elements. The @rails/ujs library will handle the form submission and response without requiring custom JavaScript.


// HTML
<form action="/some_path" method="post" data-remote="true">
  <input type="text" name="example" />
  <input type="submit" value="Submit" />
</form>

// JavaScript
import Rails from '@rails/ujs';
Rails.start();

// This will automatically handle the form submission via AJAX

Confirmation Dialogs

This feature allows you to add confirmation dialogs to your links and buttons by adding `data-confirm="Are you sure?"`. The @rails/ujs library will show a confirmation dialog before proceeding with the action.


// HTML
<a href="/some_path" data-confirm="Are you sure?">Delete</a>

// JavaScript
import Rails from '@rails/ujs';
Rails.start();

// This will automatically show a confirmation dialog before proceeding with the link action

Other packages similar to @rails/ujs

FAQs

Package last updated on 23 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc