2012-07-02 3 views
4

dojo에서 확인 대화 상자를 작성하는 방법은 무엇입니까? do ok 대화 상자 (javascript 확인 ​​대화 상자 없음)로 단추 누르기에 나타나는 ok 취소 대화 상자를 갖고 싶습니다. 지금까지 나는 클릭 이벤트에 대해서만 대화 상자를 표시 할 수 있습니다. Heres는 내 코드 :이 확인 대화 상자를 취소 할 수있는 방법dojo에서 대화 상자 확인

<script type="text/javascript"> 
dojo.require("dijit.form.Button"); 
dojo.require("dijit.Dialog"); 

var secondDlg; 
dojo.ready(function(){ 
    // create the dialog: 
    secondDlg = new dijit.Dialog({ 
     title: "Programmatic Dialog Creation", 
     style: "width: 300px", 
    draggable:false 
    }); 
}); 
showDialogTwo = function(){ 
    // set the content of the dialog: 
    secondDlg.set("content", "Hey, I wasn't there before, I was added at " + new Date() + "!"); 
    secondDlg.show(); 
} 
</script> 
</head> 
<body class="claro" style="margin-right:10px;"> 
<button id="buttonTwo" data-dojo-type="dijit.form.Button" data-dojo-props="onClick:showDialogTwo" type="button">Show me!</button> 
</body> 

?

답변

0

위의 해결책은 대화 상자의 오른쪽 상단에있는 작은 십자가를 고려하지 않습니다.

내가했던

, 오래 전, 대화 상자의 작은 스위트, 당신은 당신이 그들을 좀 걸릴 수 있습니다 그래서 난 그냥 오늘 github에 그들을 업로드 특히 ConfirmDialog.js , 여기에 몇 가지 행복을 찾을 수 있습니다 : http://github.com/PEM-FR/Dojo-Components/tree/master/dojox/dialog

을 "그대로"또는 사소한 변경으로 사용 가능해야합니다.

2
<script type="dojo/method" event="onClick"> 
        var dialog = new dijit.Dialog({ 
         title: "Delete Switch Type", 
         style: "width: 400px", 
         content : "Do you really want to delete ?????<br>" 
        }); 
        //Creating div element inside dialog 
        var div = dojo.create('div', {}, dialog.containerNode); 
        dojo.style(dojo.byId(div), "float", "left"); 

        var noBtn = new dijit.form.Button({ 
           label: "Cancel", 
           onClick: function(){ 
            dialog.hide(); 
            dojo.destroy(dialog); 
           } 
          }); 

        var yesBtn = new dijit.form.Button({ 
           label: "Yes", 
           style : "width : 60px", 
           onClick : <your function here>, 
           dialog.hide(); 
        dojo.destroy(dialog); 
           } 
          }); 
            //adding buttons to the div, created inside the dialog 
        dojo.create(yesBtn.domNode,{}, div); 
        dojo.create(noBtn.domNode,{}, div); 
        dialog.show(); 
       </script> 

이 코드는 버튼의 클릭 이벤트에서 인라인 dojo/메소드로 사용됩니다. 당신은 어쨌든 수정할 수 있습니다