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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:03:20+00:00 2026-06-11T06:03:20+00:00

I am using Ruby on Rails 3.2.2 and the jQuery-Rails 2.0.2 gem (including the

  • 0

I am using Ruby on Rails 3.2.2 and the jQuery-Rails 2.0.2 gem (including the jQuery UI). I have a jQuery UI Dialog window that is open when I click on a “new comment” link present in the front-end content. When the dialog window is open it is performed a AJAX HTTP request to a my controller action that make it to render and “populate” the modal window body-content with a HTML form.

I would like to implement my view so that after the form is successfully submitted the front-end content change this way: the trigger link text change form “new comment” to “edit comment”.

How can I make that? What do you advice about?


Note: The form is submitted in turn by performing a AJAX HTTP request.

  • 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-11T06:03:22+00:00Added an answer on June 11, 2026 at 6:03 am

    It all depends on how you submit that form to the server.

    If the form you are submitting has set the :remote => true attribute it will be sent to the server through an AJAX call and the server will be able to do differentiate it from a regular non-ajax form request:

    respond_to do |format|
      format.js  #this renders the <actionname>.js.erb file and executes it on the client
    end
    

    The jquery_ujs helper will then execute javascript code that the server returned to him.

    You can just write arbitrary JavaScript code in your <actionname>.js.erb file that could look like this:

    $('#trigger_link').text('edit comment');
    

    If you are not using the remote form but rather do a normal $.ajax call you can simply hook into the success callback that jQuery provides, but I guess that’s obvious.

    Update:

    Seems like the problem is that you don’t know what link triggered the opening of the Dialog.

    Usually somewhere you have a jQuery function that opens the dialog for you. When rendering the initial list that contains the trigger links I assume you have some way of differentiating them from other links on the page (maybe through a css class like .trigger).

    you can then do:

    $('.trigger').click(function() {
      window.trigger_link = this;
    });
    

    Note that this little snippet above does not overwrite your existing click event handler that opens the popup. It gets executed too.

    So now that we keep track of the link that opened the window (the window opens on clicking the trigger link – and we always save the last clicked trigger link) we can do the following once the form has been submitted:

    $(window.trigger_link).text('edit comment');
    

    Since window.trigger_link refers to the correct link.

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

Sidebar

Related Questions

I have a Ruby on Rails page that loads another page using jquery. I
Using Ruby 1.8.7-p358, Rails 3.0.12, gem responder, gem simple-form; jquery_ujs.js I have a form
I am using Ruby on Rails v3.2.2 and the jquery-rails v2.0.2 gems (including jQuery
I'm using jquery-mobile with Ruby On Rails. I want to create a button link
I've installed ruby on rails using gem install rails and got the message that
I'm using ruby on rails + jquery ajax My function is for user check
I'm using Ruby on Rails with jQuery and trying to do the following: <%=
I am trying to make a auto complete box using ruby on rails, jquery
I'm using rvm 1.15.6 and ruby-1.9.3-p194. I've created a new Rails application with the
I've started a new rails project using the following gemfile : source 'https://rubygems.org' gem

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.