I have a partial view "taskrow" that will return a table row, I am using this to show rows in tables as soon as they have been updated. I need to replace the row with class "tasks" and replace it with the row that is loaded, but am struggling with the syntax. I believe the code below is inserting a tr into a tr. I have tried for ages to use a combination of replaceWith and load() but have not managed to get this working. Could someone help me with this?
$(elem).parent().find("tr.tasks").load("@Url.Action("TaskRow", "Task")", { "id": id});
You need something like this instead:
$.get('@Url.Action("TaskRow", "Task")', {'id': id}, function(data) {
$(elem).closest('table').find('tr.tasks').replaceWith(data);
});
var newRow = '<tr><td>blahh blah</td><td>blah...</td></tr>';
$('#tempID').replaceWith(newRow);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With