Click here to Skip to main content
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 11-Jul-13 0:43am
Edited 11-Jul-13 0:59am
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 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 174
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,665


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 11 Jul 2013
Copyright © CodeProject, 1999-2014
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