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 8375459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:11:00+00:00 2026-06-09T15:11:00+00:00

I have a multi-step form that I set up in rails 3 using this

  • 0

I have a multi-step form that I set up in rails 3 using this tutorial: http://railscasts.com/episodes/217-multistep-forms

I can progress to the next and previous steps in the form by clicking the “continue” and “back” submit buttons, respectively.

I’ve plugged in a payment form via Stripe on the final page of the form, and this requires the following jQuery in coffeescript:

videos.js.coffee

jQuery ->
  Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content'))
  video.setupForm()

video =
  setupForm: ->
    $('#new_video').submit ->
      if $('#card_number').length
        video.processCard()
        false
      else
        true

So here’s the problem I’m having. Everything with the final page of my form works except for the “back” button, which acts as though I’m clicking “continue”. This is clearly because the jQuery is referencing all the “.submit” buttons on the form.

I want to assign an id, “#uploadsubmit” to the “continue” submit button on this final page of the form, so that I can use the back button again. How do I reference this id in the jQuery coffeescript?

  • 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-09T15:11:01+00:00Added an answer on June 9, 2026 at 3:11 pm

    It’s not that jQuery is referencing all the buttons, but rather it’s binding to the submit event of the form. If you ID’d the continue button specifically and added your card processing there, you’d miss form submissions triggered by other means (like pressing the “enter” button).

    What you need to be able to do is determine which submit button was clicked. There are ways to do this without jQuery, but they’re not cross-browser friendly. You can do it with jQuery easily, however, by marking the button that was clicked, e.g. by adding a class.

    $('#new_video input:submit').click ->
      $(this).addClass('wasclicked')
    
    $('#new_video').submit ->
      clickedBtn = $(this).find('.wasclicked')
    
      if clickedBtn.attr('name') !== 'back_button' && $('#card_number').length
        video.processCard()
        clickedBtn.removeClass('wasclicked')
        false
      else
        true
    

    So when a button is clicked, it gets marked with the .wasclicked class. On submit, the button is found, and if it’s not the back button you can go ahead and process the card. The ‘wasclicked’ button is then removed (in case the credit card processing fails, etc).

    You could also just store the clicked name and avoid using classes, something like this should work:

    clickedName = null
    
    $('#new_video input:submit').click ->
      clickedName = $(this).attr('name')
    
    $('#new_video').submit ->
      if clickedName !== 'back_button' && $('#card_number').length
        video.processCard()
        clickedName = null
        false
      else
        true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi-step form (a wizard) that I created using this railscast: http://railscasts.com/episodes/217-multistep-forms
I have a multi-step Rails 3 form that I set up using this railscast:
I'm creating a multi-part form in the style that Ryan Bates describes here: http://railscasts.com/episodes/217-multistep-forms
I have a multi-step order form built in this manner: Step 1: Choose category
I have a large multi-step form that will insert a record into a database.
I currently have a Multi step form set up in my CodeIgniter app and
I have a multi-step form where the form on Step3 submits to Step4.php. Step4
I have got a the following problem: I have got multi-step form where in
I have a longer running multi-step process using BackgroundWorker and C#. I need to
I'm using Symfony2 and CraueFormFlowBundle to create a multi-step form. Everything is going well

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.