Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:01:58+00:00 2026-06-10T02:01:58+00:00

I have a page with multiple forms on it. These forms are using a

  • 0

I have a page with multiple forms on it. These forms are using a data attribute data-remote=”true
so that the Rails jquery-ui-rails.js automatically adds events to submit these forms via javascript.

When a user submits any of these forms I would like to add a class so I can style it as needed. As Rails is automatically adding the ajax handlers to submit the form I can’t just add this class at the point the handlers are added – I need to manually add code for this myself (I think).

The following code was my first attempt – this attaches okay, but as ajaxStart is a global event it triggers it simultaneously for every form on the page.

$('form').ajaxStart(function(e) {
  console.log("element is " + ($(e).attr('id')));
  return $(e).addClass('submitting');
})

I have also tried beforeSend as according to http://docs.jquery.com/Ajax_Events this is a local event and seems to be the only relevant one:

$('form').beforeSend(function(e) {
  console.log("element is " + ($(e).attr('id')));
  return $(e).addClass('submitting');
})

However, this raises the error:

Uncaught TypeError: Object [object Object] has no method 'beforeSend' 

How can I attach this event to all of the forms on my page so that it fires once per ajax submission, and only for the current form that is being submitted?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:02:00+00:00Added an answer on June 10, 2026 at 2:02 am

    I think you can use ajax:beforeSend.rails and ajax:complete.rails events:

    https://github.com/rails/jquery-ujs/blob/8b147fb023f0d13deebea750e7e9827b6d3bc8ba/src/rails.js#L405

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple ajax forms on page that cointain same elemets, I have jquery
I have a page with multiple forms that I submit via Ajax POSTs serially.
I have multiple forms on a page, for each of them I want the
I have multiple forms for lots of products on my page and want to
I have a page with multiple YouTube embedded players that I need to listen
I have multiple forms on a page which pass an id to the controller
I have a page with multiple forms on it. Each form has it's own
I have an aspx page that contains regular html, some uicomponents, and multiple tokens
In MVC3 Razor, how do you create a page with multiple forms, so that
I have a page that contains several forms that are identical throughout a page.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.