Skip to content

Latest commit

 

History

History
45 lines (24 loc) · 831 Bytes

README.md

File metadata and controls

45 lines (24 loc) · 831 Bytes

jquery-disablewith

jQuery plugin for rails applications, which provides an simple method to disable AJAX button and replace its text while the request is running.

Example

somewhere in your views:

= link_to "Send request", url, remote: true

then in application.js you can write something like that:

$("a").disableWith();

It will replace "Send request" words with "Processing..." before the request start, and turn it back on complete. It will also disable the click event on the element until the AJAX request complete.

You can change the text:

$("a").disableWith({ text: "Loading..." });

Requirements

  • jquery-rails

Installation

Add to the Gemfile

gem jquery-disablewith

Then run

bundle install

Usage

Add

//=require jquery.disablewith

into the application.js