Dojo确认对话框'缺失:属性ID后'和'找不到节点'

时间:2013-08-21 09:16:29

标签: javascript dojo dialog confirm

我找到了here带有yes-no按钮的dojo confim对话框。我稍微修改了它,但它不起作用。 (我需要补充一点,即使没有修改它也不起作用)

Firebug揭示了两种问题:

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

  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=

毋庸置疑,尽管如此,我仍然是一名道场大师 对我来说似乎合乎逻辑,所以我不知道如何修复它。

这是我的代码:`

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

我称之为:

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

非常感谢任何建议。

1 个答案:

答案 0 :(得分:0)

您的问题出现在以下代码中:

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

onClick函数错误,应为

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