Click here to Skip to main content
11,711,750 members (79,084 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET MVC
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
$(".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 10-Jul-13 23:43pm
Edited 10-Jul-13 23:59pm
v2
Comments
Tadit Dash at 11-Jul-13 5:50am
   
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");
ratnakargudipati at 11-Jul-13 5:55am
   
I have done that still not closing
ratnakargudipati at 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'"
Tadit Dash at 11-Jul-13 6:06am
   
Try like below...

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

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

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

click: function () {
     $.ajax({
                ......
                ......
     });
HERE PUT $('#UPDATEPANELID').HIDE();
     $(this).dialog("close");
  Permalink  
Comments
ratnakargudipati at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 434
1 CHill60 280
2 OriginalGriff 170
3 Peter Leow 130
4 Abhinav S 125
0 CHill60 280
1 Sergey Alexandrovich Kryukov 125
2 Andy Lanng 120
3 Abhinav S 95
4 Maciej Los 95


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 11 Jul 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100