We help IT Professionals succeed at work.

Problem with Modal Dialog jquery and Function Close

HerediSoft
HerediSoft asked
on
Hi, i have a problem with a modal dialog, the close function dont close the modal, i dont know why?  

"btn" is it button that I click.

My code is the next:

    $("#btn").click(function () {
     
        aRow = jQuery("#BudgetGrid").jqGrid('getGridParam','selrow');
        if (aRow)
        {
            var ret = jQuery("#BudgetGrid").jqGrid('getRowData',aRow);
            var iId = ret.Id;
            $('#my-dialog').dialog({
                autoOpen: false,
                width: 400,
                datatype:"json",
                resizable: false,
                modal: true,
                open: function (event, ui) {
                   $(this).load("@Url.Action("_BudGetForm")",{id:iId});

                },
                buttons:
                {
                "Ok":function(){
                    $.ajax({
                        url: '/Budget/BudgetUpdate/',
                        type: 'POST',
                        cache: false,
                        loadComplete: function() {
                                        alert("grid is loaded/reloaded");
                        },
                        onComplete:function(){
                            RefrescarGrid();
                        },
                        data: { iBudgetId: $("#hdBudgetId").val(), sDescription:$("#DESCRIPTION").val()  },
                        success: function (result) {
                                    $("#BudgetGrid").GridUnload();
                                    CreateGrid();
                                    console.log(result);
                                    if (result!=undefined) {
                                       
                                    } else {
                                    jAlert("Data error read!!");
                    }
                        }
                    });
                }
                ,
                Close:function(){
                    alert('dddd');
                    $(this).dialog('close');     ///// DONT WORK!!
                    $(this).dialog("destroy").remove()   //// DONT work!!!
                }
            }
            });

            $('#my-dialog').dialog('open');
           
        }
        else
        {
        jAlert("Select line to edit!!..")
        };
    });

Regards and thanks for you help! HerediSoft-527956.flv HerediSoft-527956.flv
Comment
Watch Question

Michel PlungjanIT Expert
Top Expert 2009

Commented:
Can you create a jsfiddle.net for it?

Author

Commented:
Thanks for answer!, basically i need when the modal window show it, my button close created, allow close the modal window no with button "x".

Example:

http://jsfiddle.net/ksGCb/6/

Regards,


Had that re-code the script in my solution, the project is MVC 3 and jquery and the solution was return a partial view.
 
Thanks for you help mplungjan. ;)

Author

Commented:
find the solution in the next url :

http://iwantmymvc.com/dialog-form-with-jqueryui-and-mvc-3
Michel PlungjanIT Expert
Top Expert 2009

Commented:
Great you found it