views:

101

answers:

1

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;
    });
});
+2  A: 
T.J. Crowder
@T.J. Crowder Data posting works great now. Problem is that the dialog now does not close. Suggestions?
Ben Dauphinee
@Ben Dauphinee: Ah, yes -- updated.
T.J. Crowder