jQuery Dialog form serialize reposting incorrect data on subsequent uses
Posted
by Ben Dauphinee
on Stack Overflow
See other posts from Stack Overflow
or by Ben Dauphinee
Published on 2010-06-02T14:01:56Z
Indexed on
2010/06/02
14:03 UTC
Read the original article
Hit count: 263
I'm working with forms inside jQuery Dialog, and am having some issues with the data it's posting. First load and save works fine, posts the correct data. Until I refresh the page though, every subsequent load seems to work, as in the correct data is in the form, however, when saved, the data from the first load is what is posted every time.
function formdialog(url, tack, divid, scriptload){
$.getJSON(url+tack+"/form", function(data){
var formwin = '<div><form id="formdialog">'+data['form']+'</form></div>';
var dialog = $(formwin).dialog({
title: data['title'],
autoOpen: false,
modal: true,
buttons: {
"Save": function(){
$.post(url+tack+"/process",
$("#formdialog").serialize(),
function(data){
alert($("#formdialog").serialize());
$(this).dialog('close');
$(this).remove();
}
);
},
"Cancel": function(){$(this).dialog('close'); $(this).remove();}
}
});
dialog.dialog("open");
});
}
$(function(){
$("a.edlnk").click(function(){
var url = $(this).attr("href");
formdialog(CONFIG_HREF_SITE+"ajax/"+appControl, "/"+url, divid);
return false;
});
});
© Stack Overflow or respective owner