Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have view of employee list. For editing of an employee i have a opened a editemployee partial view in a modal popup. the popup code is below
HTML
$(".empEdit").on("click", function () {
           var id = $(this).attr('id');
           $("#dialog-edit").load("EditEmployee/" + id);
           $("#dialog-edit").dialog({
               title: 'Employee Edit',
               height: 655,
               width: 400,
               modal: true,
               buttons: [{
                   id: "SubmitButton",
                   text: "Update",
                   click: function () {
                       $.ajax({
                           type: "Post",
                           url: "EditEmployee",
                           data: "EmpId=" + $("#EmpId").val() +
                               "&EmpName=" + $("#EmpName").val() +
                               "&EmpSal=" + $("#EmpSal").val() +
                               "&EmpContact=" + $("#EmpContact").val() +
                               "&EmpGender=" + $("#EmpGender").val() +
                               "&EmpDOJ=" + $("#EmpDOJ").val() +
                               "&EmpDOB=" + $("#EmpDOB").val(),
                           success: function (data) {
                               var response = $(data);
                               $("#empList").find("tr").eq(response.data("EmpId")).replaceWith(response);
                               $("#dialog-edit").dialog("close");
                           },
                           error: function (data) {
                               alert("Employee Updation Failed");
                           }
                       });
                   }

               }]
           });
       });


When i am clicking on Update button the model popup is not closing
please anybody help. What I did wrong.

I got an error like "cannot call methods on dialog prior to initialization; attempted to call method 'close'"
Posted
Updated 10-Jul-13 23:59pm
v2
Comments
Try writing the close function after the ajax call and don't write it inside the success like below...

click: function () {
$.ajax({
......
......
});

$("#dialog-edit").dialog("close");
[no name] 11-Jul-13 5:55am    
I have done that still not closing
[no name] 11-Jul-13 5:58am    
I have debugged that one getting the error like
"cannot call methods on dialog prior to initialization; attempted to call method 'close'"
Try like below...

click: function () {
$.ajax({
......
......
});

$(this).dialog("close");
[no name] 11-Jul-13 6:14am    
I have tried with your code but no luck same error i am getting

1 solution

PHP
click: function () {
     $.ajax({
                ......
                ......
     });
HERE PUT $('#UPDATEPANELID').HIDE();
     $(this).dialog("close");
 
Share this answer
 
Comments
[no name] 11-Jul-13 7:29am    
This is also not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900