I'm using jQuery to bring up a jQuery UI dialog and in it there is a form. I then use the ajax function of jQuery to submit my form data. The problem lies here....I have a bunch of stuff in a table with a edit button. This edit button is supposed to bring up the jQuery UI dialog so I can edit the fields and submit the changes.
I make my changes and then during the submit, it submits data from the first link in my table.
Here is how my JS code looks
$('.edit_task').each(function() {
var $link = $(this);
var $dialog = $('<div></div>')
.load($link.attr('href'))
.dialog({
autoOpen: false,
title: "Edit Task",
width: 700,
height: 550,
modal: true,
buttons: {
"Save": function() {
$.ajax({
url: $link.attr('href'),
type: "POST",
data: $("#EditTaskForm").serialize(),
dataType: "html",
async: true,
cache: false,
error: function()
{
alert("Error: An error occured while trying to update a task.");
},
success: function()
{
$(this).dialog('close');
location.reload();
}
});
},
"Cancel": function () { $(this).dialog('close'); }
}
});
$link.click(function() {
$dialog.dialog('open');
return false;
});
});
I've been trying to fix this problem for days and I can't seem to find out what the problem is.
Edit: Here is the form HTML http://pastebin.com/knh1AVGk
id="EditTaskForm"?