Dojo 使用href属性时,操作栏未显示在dijit对话框中

Dojo 使用href属性时,操作栏未显示在dijit对话框中,dojo,Dojo,我有以下代码 var dlg = new dijit.Dialog({ "title": "my dialog", "style": "width: 800px;", "id": "myDlg", "href":"some url" }).placeAt(dojo.body()); var actionBar = dojo.create("div", { "class": "dijitDialog

我有以下代码

var dlg = new dijit.Dialog({
        "title": "my dialog",
        "style": "width: 800px;",
        "id": "myDlg",
        "href":"some url"
    }).placeAt(dojo.body());


    var actionBar = dojo.create("div", {
        "class": "dijitDialogPaneActionBar"
    }, dlg.containerNode);

    new dijit.form.Button({
        "label": "Ok"
    }).placeAt(actionBar);
    new dijit.form.Button({
        "label": "Cancel"
    }).placeAt(actionBar);

    dlg.show();
当我用一些静态内容替换href时,此代码对话框显示url内容,但操作栏不显示。操作栏工作正常。可能有什么问题?

在dojo对话框中使用“href”时,每次打开/显示对话框时,来自href的内容都作为ajax调用加载。因此,这里发生的是首先添加您的操作栏和按钮,然后将href加载到对话框中,这将覆盖现有的操作栏和按钮-每次!! 因此,要实现这一点,您可以确保在href加载完成后添加操作栏。为此,我们使用“show”方法返回的延迟对象

但是,我建议不要使用这种方法,因为每次都会创建操作栏和按钮小部件。所以,我在dialog对象中添加了一个参数“firstTime”,以避免它。因此,操作栏和按钮只包装一次。 希望这有帮助

var dlg = new dijit.Dialog({
    "title": "my dialog",
    "style": "width: 800px;",
    "id": "myDlg",
    "href":"some url"
}).placeAt(dojo.body());

dlg.show().then(function() {
  if(dlg.firstTime) {
     var actionBar = dojo.create("div", {
        "class": "dijitDialogPaneActionBar"
     }, dlg.containerNode);

     new dijit.form.Button({
       "label": "Ok"
     }).placeAt(actionBar);
     new dijit.form.Button({
       "label": "Cancel"
     }).placeAt(actionBar);
     dlg.firstTime=true;
   }
});