robert trudel
robert trudel

Reputation: 5749

dialog display automatically when i load web page

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" />

Upvotes: 0

Views: 43

Answers (1)

Chase
Chase

Reputation: 9362

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/

Upvotes: 2

Related Questions