2013-10-23 8 views
0

웹 페이지를로드 할 때 자동으로 열리는 대화 상자가 있습니다. 나는 그것을 원하지 않는다.웹 페이지를로드 할 때 대화 상자가 자동으로 표시됩니다.

가 나는 이미지를 넣어 내가 그것을 클릭하면, 나는 열려있는 대화

내 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 부분을 원하는 당신은에 AutoOpen 옵션을 추가 할 필요가

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

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

답변

2

및 이 값을 false로 설정하면 페이지가로드 될 때 열리지 않고 열린 함수를 호출 할 때만로드됩니다.

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

근무 예 :이 대화 상자를 엽니 다 클릭하면 http://jsfiddle.net/Eh89t/1/

+0

이상하게, 그것은 제가 추가 내 jsfiddle을 확인하기위한 –

+0

잘 작동 immidiately 마감했다. 그것의 아직도 닫히는 경우에 당신은 열리는 그것에 그것을 닫고있는 다른 어떤 사건이있다. – Chausser

관련 문제