0

When i load my web page, i have a dialog who open automatically. I don't want that.

I put a image and when i click on it, i would like dialog open

my js

       $("#deleteReportButton").click(function() {
             $("#deleteReportConfirm").dialog("open");
        });


        $("#deleteReportConfirm").dialog({
            resizable: false,
            height: 140,
            modal: true,
            buttons: {
                "Delete report": function() {
                    $(this).dialog("close");
                },
                Cancel: function() {
                    $(this).dialog("close");
                }
            }
        });

html part

       <div id="deleteReportConfirm" title="Delete report?" style="display:none">
           <p>....</p>
       </div> 

       <img id="deleteReportButton" src="/plato/resources/images/delete.png" />

1 Answer 1

2

You need to add the autoOpen option and set it to false, this will stop it from opening when the page is loaded and only load when you call the open function.

$("#deleteReportConfirm").dialog({
        autoOpen: false,
        resizable: false,
        height: 140,
        modal: true,
        buttons: {
            "Delete report": function() {
                $(this).dialog("close");
            },
            Cancel: function() {
                $(this).dialog("close");
            }
        }
    });

Working example: http://jsfiddle.net/Eh89t/1/

Sign up to request clarification or add additional context in comments.

2 Comments

strangely, when i click to open this dialog, it closed immidiately
works fine for me check my jsfiddle i added. If its still closing when opened you have some other event that is closing it on open.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.