Dojo确认对话框'缺少:在属性id'之后;和'找不到节点'

Dojo Confirm dialog 'missing: after property id' and 'node was not found'

本文关键字:之后 id 节点 属性 找不到 确认 对话框 缺少 Dojo      更新时间:2023-09-26

我在这里发现了一个带有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();">

如有任何建议,不胜感激。

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

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);
                 }
             });