2
我想創建一個Dojo小部件有一個非常簡單的HTML模板:Dojo小部件與模板,小部件的負載變化模板(添加DOM元素)
<div id="contentExternal"></div>
然後我想要加載某些URL的窗口小部件的負載從外部服務。然後在url加載後,我想把一個與src參數等於這個加載的url。我已經寫:
dojo.provide("dojoModules.ExternalWebsitePane");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dojoModules.ConfigurationPane");
dojo.declare("dojoModules.ExternalWebsitePane", [dijit._Widget, dijit._Templated],
{
templateString: dojo.cache("dojoModules", "templates/ExternalWebsitePane.html"),
widgetsInTemplate: false,
constructor: function() {
}
,
startup: function() {
//Get Config
var serviceParams = new Object();
serviceParams.ServiceType = "GetConfig";
ecm.model.Request.invokePluginService("ExternalWebsitePlugin", "ExternalWebsiteService",
{requestParams: serviceParams, requestCompleteCallback: function(response) {
iframe = new Object();
iframe.src = response.configuration.value;
iframe.class = "iframe1";
var content = document.getElementById('contentExternal');
content.appendChild(iframe);
}});
}
});
但在
var content = document.getElementById('contentExternal');
content.appendChild(iframe);
代碼執行失敗,它說,內容爲空。我懷疑HTML模板的div尚未加載。我應該如何添加一個元素?或什麼時候?