Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I had a jquery dialog box in an MVC razor-view with a close button inside it. But on clicking the close button, the dialog just got hidden and not removed, so that when a click on any link on the page it doesnt work, which is not desired; noe do i want to redirect to my action method every time i close the dialog.

On clicking the 'X' button on the dialog-header, i get exactly what i want. So my senior now wants me to completely remove the 'Close' button and write "close" instead of 'X' in the header. I managed to do it editing my dialogbox thru my chrome browser console, on removing a whole lot of CSS class that the dialog-header uses.
But i cannot figure out fwhere to change the code(CSS or jquery) in my project in order to make this happen!! Please enlighten me about dialogboxes!!


here is my dialogbox:

C#
$(function () {

            $.ajaxSetup({ cache: false });
            $(".ExportStatus").live("click", function (e) {

                e.preventDefault();
                var height = 350, width = 370;  //height = 350 width = 345;
                $('<div><span class="well"  style="position: absolute; top: 85px; left: 70px"><img src="' + loaderimagePath + '" alt="Processing your request. Please wait..." /></span></div>')
                .addClass("dialog")
                .attr("id", $(this).attr("data-dialog-id"))
                .appendTo("body")
                .dialog({
                    title: $(this).attr("data-dialog-title"),                  
                    closeOnEscape: true,
                    resizable: false,
      //              close: $(this).attr("data-dialog-titlebar-close"),         
                    buttons: {
                        "Close": function () {
                            e.preventDefault();
                            $(".ui-dialog").remove();
                            $(".ui-widget-overlay").remove();
                        }
                    },
                    modal: true,
                    position: 'middle',
                    width: width,
                    height: height
                })              
                .load(this.href, function (response, status, xhr) {
                    if (status == "error") {
                        var msg = "Sorry but there was an error: ";
                        $('.dialog').html(msg + xhr.status + "<br/>" + xhr.statusText + "<br/>" + xhr.responseText);
                    }
                });
            });

Posted
Comments
pratipgd 19-Nov-12 5:11am    
You can also suggest on how i can use improve the "Close" button, so that it closes without the page reloading but the page remains active.

Tried :
buttons: {
"Close": function () {
e.preventDefault();
$(".ui-dialog").remove();
$(".ui-widget-overlay").remove();
}
AND
buttons: {
"Close": function () {
e.preventDefault();
$("#modalDialog").dialog('close');
}
}

But they dont serve my purpose

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