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

  • SEARCH
  • Home
  • 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 462255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:03:22+00:00 2026-05-12T23:03:22+00:00

I asked a similar question earlier How can I have jquery attach behavior to

  • 0

I asked a similar question earlier How can I have jquery attach behavior to an element after inserting it, but still have not found an answer. To keep things clear I am asking a new question with a different example.

Here is my code that doesn’t work.

$(document).ready(function() {  
 $('form.edit_color').live('submit',  function(){
    var form = $(this).closest('form');
    var colorRow = $(this).closest('tr');
    var action = $(form).attr('action');
    var formData = $(form).serialize();
    $(colorRow).fadeOut();
   $.post(action, formData,
    function(data) {
        $(form).replaceWith(data);
        $(colorRow).fadeIn();           
    });
    return false;
  });
});

What happens is this, for each of my forms I can submit them through ajax and replace it with the updated form. But, then nothing happens when I click the new submit button.

  • 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-05-12T23:03:23+00:00Added an answer on May 12, 2026 at 11:03 pm

    I was thinking livequery did handle submit events, but when I was having problems with that as well, I figured I would just live() as well.

    I was also having problems finding the form, when I tried to bind to the click event of the submit button.

    As I was inspecting my submit button in firebug I realized the it was not being shown as a child of my form. That got me thinking that if firebug couldn’t figure out that my submit button was a child element of my form, what kind of trouble was jQuery having (and maybe the W3C validator was complaining for a reason).

    So I tried the same code as above on a different form that I had inside a div tag instead, and it worked, so I quickly removed the table tags from form for this question and amazingly it worked too.

    My solution will be to take the extra time to make my html valid, and to go with what is not suppose to work until jQuery 1.3.3, http://docs.jquery.com/Release:jQuery_1.3.2.

    Below is my current code, I will need to figure out to properly markup the form.

    $(‘form.edit_color’).live(‘submit’, function(){
    var form = $(this);
    var colorRow = $(this).closest(‘div.color_form’);
    var action = $(form).attr(‘action’);
    var formData = $(form).serialize();
    $(colorRow).fadeOut();
    $.post(action, formData,
    function(data) {
    $(form).replaceWith(data);
    $(colorRow).fadeIn();
    });
    return false;
    });

    <div class="color_form">
    <% form_for color, :url => admin_color_path(color) do |f| -%>
     <div style="background: #<%= color.value %>"></div>
      <div><%= f.text_field :title %></div>
       <div><input type="text" size="30" name="color[value]" class="colorpickerfield" value="<%= color.value %>" /></div>
        <div style="text-align:left">
         <% Color.types.each do |type, name| %>
          <div>
           <%= color_types_checkbox(color, type) %>
           <%= name %>
          </div> 
         <% end %>
        </div>
       <div>
      <%= f.submit "Update", :class => 'submit' %>
     </div>
    <% end %>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have asked a similar question earlier, but this time i need a method
I already asked similar question here, but I still get some errors, so I
I asked similar question here , I am wondering how you can achieve same
I've already asked similar question on this issue on stack overflow already, but I
I asked a similar question before ( integer-vs-char-for-db-record-property ) but stumbled upon something that
i am sorry to ask again since i asked something similar to this earlier,
I asked similar question one month ago: Inheritance though composition? I took the examples
Someone asked a similar question before , getting the following error when I run
How can I generate execution plan for an oracle loop query like below: BEGIN
Can you share your thoughts how would you implement data versioning in PostgreSQL. (I've

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.