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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:25:32+00:00 2026-05-24T22:25:32+00:00

FOUND THE PROBLEM: Just needed to replace row.replaceWith with row.parent().parent().replaceWith() . I’m trying to

  • 0

FOUND THE PROBLEM:
Just needed to replace row.replaceWith with row.parent().parent().replaceWith().


I’m trying to update a WebGrid row with JQuery after I’ve clicked a submit button in a modal dialog, but the updated data just append the last column, not the whole row as I want.

Let’s say I want the table to look like this after the update:

ID - Name - Phone number

But with my code it looks like this after the update:

ID - Name - ID - Name - Phone number 

as it just replaces the last column with a new table within the last column with the updated data.

I’m getting the correct data as output, but in the wrong place in the row.

Please help! 🙂

Here is the Javascript code:

$(function () {
    $("#edit-event-dialog").dialog({
        resizable: false,
        height: 300,
        modal: true,
        autoOpen: false,
        open: function (event, ui) {
            var objectid = $(this).data('id');
            $('#edit-event-dialog').load("/Events/CreateEditPartial", { id: objectid });
        },
        buttons: {
            "Save": function () {
                var ai = {
                    EventID: $(this).data('id'),
                    Name: $("#Name").val(),
                    Phone: $("#Phone").val()
                };
                var json = $.toJSON(ai);
                var row = $(this).data('row');

                $.ajax({
                    url: $(this).data('url'),
                    type: 'POST',
                    dataType: 'json',
                    data: json,
                    contentType: 'application/json; charset=utf-8',
                    success: function (data) {
                        var grid = $(".pretty-table");
                        row.replaceWith('<tr><td>' + data.ev.EventID + '</td><td>' +
                        data.ev.Name + '</td><td>' + data.ev.Phone + '</td></tr>');
                    },
                    error: function (data) {
                        var data = data;
                        alert("Error");
                    }
                });
                $(this).dialog("close");
            },
            Cancel: function () {
                $(this).dialog("close");
            }
        }
    });

    $("#event-edit-btn").live("click", function () {
        var url = $(this).attr('controller');
        var row = $(this);
        var id = $(this).attr('objectid');

        $("#edit-event-dialog")
            .data('id', id)
            .data('url', url)
            .data('row', row)
            .dialog('open');

        event.stopPropagation();
        return true;
    });
  • 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-24T22:25:33+00:00Added an answer on May 24, 2026 at 10:25 pm

    You have set row to $(this) which is your case represents $("#event-edit-btn") ( btw i suggest using classes as identifiers, but it’s not a problem ). Later on you replace your actual button with the new <tr> set but what you actually need to do is traverse to the tr parent of that button and replace it.

    Change your live handler to:

    $("#event-edit-btn").live("click", function () {
    
           var url = $(this).attr('controller');
           var row = $(this).closest('tr'); //or use some #id or .class assigned to that element
           var id = $(this).attr('objectid');
    
           $("#edit-event-dialog")
               .data('id', id)
               .data('url', url)
               .data('row', row )
               .dialog('open');
    
           event.stopPropagation();
           return true;
    
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, so I'm quite new to jQuery, but found this bizzare problem just now,
I have found a problem with use JQuery timeout, i have a page with
My answer: After getting annoyed, I have found a solution. The problem was indeed
Hello Guys, I was just trying to create a plugin, and I needed it
We have encountered a very strange class not found problem in our web app
I found a problem with the XML Serialization of C#. The output of the
Ok I found the problem, it was an environmental issue, I had the same
I've made a very simple aspect, and found a problem when debugging it (see
Related to a question I asked earlier here , I've found a problem which
I found an odd problem when I run a simple csh script on Solaris.

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.