我有以下代码:
function handlesomeObjDelete(someObj) {
query('#someObj-delete-link-'+someObj.id).on('click',function(){
var youSureDlg = new Dialog({
title: 'Delete someObj',
width:'250px',
id:'delete-someObj-dlg'+someObj.id,
content:'Are you sure you want to delete this someObj?'
});
var yesBtn = new Button({
label: 'Yes',
type: "button"
});
var noBtn = new Button({
label: 'No',
type: "button"
});
on(yesBtn,'click',function(){
request("someUrl/"+someObj.id, {
handleAs: "json",
type:'delete',
headers: {
"X-Requested-With": "",
"Content-Type": 'application/json; charset=utf-8'
}
}).then(function(){
alert('deleted');
});
});
on(noBtn,'click',function(){
youSureDlg.hide();
});
yesBtn.placeAt(youSureDlg);
noBtn.placeAt(youSureDlg);
//youSureDlg.startup();
youSureDlg.show();
});
}
我收到以下错误:
TypeError: refNode is null
packs[name] = packageInfo;
TypeError: youSureDlg.show is not a function
dojoSniffConfig
我已经加入了dijit.Dialog。如果我再次尝试创建Dialog,我会:尝试注册id == someid的widget,但该id已经注册
任何可能出错的想法?
感谢。
答案 0 :(得分:0)
尝试这样做:
if(!youSureDlg){
var youSureDlg = new Dialog({
title: 'Title',
id: "someID",
content: "",
style: "width:250pt",
});
youSureDlg.show();
}
else {
youSureDlg.show();
}
Dialog独立,是一个独立的Box,不会绑定到另一个div或其他东西。
检查出来:http://dojotoolkit.org/reference-guide/1.9/dijit/Dialog.html#dijit-dialog
希望它对你有所帮助。
<强> UPDATE1 强>: 当您想要启动未删除的窗口小部件或使用它后取消注册时,会出现“尝试注册....”错误。您可以通过检查窗口小部件是否已存在来处理此问题。检查我的代码 - 我已经更新了它。
同时查看旧帖子:Dojo dialog close event on X (top-right)和Dojo and unregistering widgets
此致,Miriam
答案 1 :(得分:0)
似乎无法找到您的源参考节点。 这是小部件代码锚定的位置。新对话框中的第二个参数 &#39; yousuredlg&#39;应该是你的HTML中的实际div。
离。
<强> HTML 强>
<div>
<div id="yousuredlg"></div>
<button id="goButton">Go</button>
</div>
<强> JS 强>
require(["dojo", "dijit", "dijit/Dialog", "dojo/on"], function (dojo, dijit, Dialog, on) {
var youSureDlg;
on(dojo.byId("goButton"), "click", function () {
if (!youSureDlg) {
youSureDlg = new Dialog({
title: 'Title',
width: '250px',
id: 'someid',
content: 'some content'
}, 'yousuredlg');
}
youSureDlg.show();
});
})