Click here to Skip to main content
12,404,478 members (74,604 online)
Rate this:
 
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
Updated 10-Jul-13 23:59pm
v2
Comments
Tadit Dash 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 11-Jul-13 5:55am
   
I have done that still not closing
ratnakargudipati 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 11-Jul-13 6:06am
   
Try like below...

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

$(this).dialog("close");
ratnakargudipati 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 11 Jul 2013
Copyright © CodeProject, 1999-2016
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