我正在尝试使用Dojo显示警告框。警报框行为将是无模式的。所有工作都是通过一个具有addScript / CSS功能的Javascript完成的,这些功能运行良好。虽然我不打算使用Dojo显示警报。这是我的代码:
// DojoThemes and Libraries
addStylesheet('http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css');
addStylesheet('http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/tundra/tundra.css');
addScript('http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.js');
//dojo.require("dojo.ready");
//dojo.require("dijit.Dialog");
var dojoDialogBox = document.createElement('script');
dojoDialogBox.innerHTML = 'require(["dojo/ready", "dijit/Dialog"], function(ready, Dialog){ ready(function(){ myDialog = new Dialog({ title: "My Dialog", content: "Test content.", style: "width: 300px" }); }); });';
document.getElementsByTagName('head')[0].appendChild(dojoDialogBox);
function myFuncc() {
myDialog.show();
}
答案 0 :(得分:0)
<script>
addStylesheet('http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css');
addStylesheet('http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/tundra/tundra.css');
addScript('http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.js');
</script>
<!--
closing script tag here will allow dojo.js script
tag to get written - otherwise
'require' is an undefined
-->
<script>
require(["dijit/Dialog", "dojo/domReady!"], function(Dialog){
myDialog = new Dialog({
title: "My Dialog",
// since we are inside a require(function() {}) closure, lets set an ID
// so that externally (from outside this require function) we can get the dialog
id:'myDialog',
content: "Test content.",
style: "width: 300px"
});
});
function myFuncc() {
dijit.byId('myDialog').show();
}
</script>