Confirm dojo dialog

How to create a confirmation dialog in dojo? I would like the ok cancel dialog box to appear when you click the button with the dojo dialog box (without the javascript confirmation dialog box). So far, I can only display the click event dialog. Here is my code:

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

How can I make it ok cancel the dialog?

+4
source share
3 answers

The above solution does not take into account the small cross in the upper right corner of the dialogue.

I already made a small set of dialogs a long time ago, here you can find some happiness, especially ConfirmDialog.js I just uploaded them to github today so you can take a look at them: http://github.com/PEM-FR/Dojo- Components / tree / master / dojox / dialog

They should be used "as is" or with minor modifications.

0
source
 <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> 

I use this code as a built-in dojo / method - in a button click event. you can still change

+2
source

Confirmation dialog is supported with Dojo 1.10.

See release notes and documentation .

+2
source

All Articles