Question

I found here a dojo confim dialog with yes-no buttons. I slightly modified it, but it does not work. (I need to add that it does not work even without the modifications)

Firebug reveals two kind of problems:

1, SyntaxError: missing : after property id
dialog.hide();

and

  2, dojo/parser::parse() error
[Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NotFoundError)" location: "https://gaia.acrys.com:8843/arranger/dojo/dojo.js Line: 226"] { constructor=DOMException, code=

Needless to say that I am lightyears from being a dojo-guru, nevertheless the code below seems logical to me, so I have no idea how to fix it.

Here is my code: `

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

        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 : alert("I clicked yes"),
                            dialog.hide();
                dojo.destroy(dialog);
                            }
                         });
                //adding buttons to the div, created inside the dialog
                dojo.create(yesBtn.domNode,{}, div);
                dojo.create(noBtn.domNode,{}, div);
    </script>`

and I call it like this:

<button data-dojo-type="dijit/form/Button" type="submit" name="deleteIdx" value="19524803" onclick="dialog.show();">

Any advice is highly appreciated.

Was it helpful?

Solution

Your problem is in following code:

var yesBtn = new dijit.form.Button({
                        label: "Yes",
                        style : "width : 60px",
                        onClick : alert("I clicked yes"),
                        dialog.hide();
            dojo.destroy(dialog);
                        }
                     });

The onClick function is wrong, should be

var yesBtn = new dijit.form.Button({
                 label: "Yes",
                 style : "width : 60px",
                 onClick : function() {
                    alert("I clicked yes"),
                    dialog.hide();
                    dojo.destroy(dialog);
                 }
             });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top