简体   繁体   English

“ Dojo确认”对话框“缺少:属性ID之后”和“未找到节点”

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

I found here a dojo confim dialog with yes-no buttons. 我在这里找到一个带有yes-no按钮的dojo confim对话框。 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: Firebug揭示了两种问题:

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. 任何建议都将受到高度赞赏。

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 onClick函数是错误的,应该是

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM