Obviously, there are many ways to do this, but here's how I would solve it. Make an ajax call before loading the dialog box to populate the contents of the dialog box, show the dialog box and then save close the dialog box and refresh the grid. These are the basics, there is an auxiliary code below. I find it good practice to return the json result from the save action to determine if the save was successfully saved, and if not an error message indicating why it was not displayed to the user.
<div id="dialog" title="Basic dialog"> <form id="exampleForm"> <input blah> <input type="button" onclick="Save()" /> </form> </div> <script> $(function() { $('.myPop').click(function() { $.get("editController/loadContents", function(data){ $("#dialog").html(data); }); $("#dialog").dialog('open'); }); }); function Save(){ $.post("/editController/Edit", $("#exampleForm").serialize(), function(data){ $("#dialog").dialog('close'); </script>
source share