dojo.parser.parse只能在第一次被调用时工作 [英] dojo.parser.parse only working first time it's called
问题描述
调用第一个对话框工作正常,但后续调用对话框无法解析dojo控件。
示例:
showParametersDialog:function(doc){
var content = doc.firstChild.firstChild.data;
var container = document.createElement('div');
container.id ='dialog';
container.innerHTML = content;
container.style.background ='transparent';
container.style.position ='absolute';
container.style.top =(document.body.clientHeight / 2) - 124 +px;
container.style.left =(document.body.clientWidth / 2) - 133 +px;
container.style.display ='block';
document.body.appendChild(container);
//设置日期字段
var date_from = dojo.byId('date_from');
var date_to = dojo.byId('date_to');
try {
date_from.value = dojo.date.locale.format(new Date(),{selector:'date'});
date_to.value = dojo.date.locale.format(new Date(),{selector:'date'});
} catch(e){
var now = new Date();
date_from.value = String(now.getMonth()+/+ now.getDate()+/+ now.getFullYear());
date_to.value = String(now.getMonth()+/+ now.getDate()+/+ now.getFullYear());
}
dojo.parser.parse();
}
所有对话框都有公共日期字段。
所以当我第一次调用这个对话框,并调用dojo.parser.parse()时,它解析对话框上的控件,但只有第一次...后,没有dojo。
任何想法?
谢谢,
Paul。
您可以使用
dojo.parser.instantiate([dojo.byId ( myDiv)]);
而不是dojo.parser.parse();
在所有未解析的对象上使用它。
您可以在这里找到更多信息:
a href =http://livedocs.dojotoolkit.org/dojo/parser =nofollow> http://livedocs.dojotoolkit.org/dojo/parser
I have a page that when a user clicks on a link for some reporting tools, it first asks them to enter some report parameters. I get the parameters dialog as a form using AJAX, based on the id of the link. Each dialog has some dojo controls on it, so I need to parse them when the dialog appears, because it is not originally part of the page.
The first dialog when called works fine, but subsequent calls to dialogs fails to parse the dojo controls.
Example:
showParametersDialog : function(doc) {
var content = doc.firstChild.firstChild.data;
var container = document.createElement('div');
container.id = 'dialog';
container.innerHTML = content;
container.style.background = 'transparent';
container.style.position = 'absolute';
container.style.top = (document.body.clientHeight / 2) - 124 + "px";
container.style.left = (document.body.clientWidth / 2) - 133 + "px";
container.style.display = 'block';
document.body.appendChild(container);
// set up date fields
var date_from = dojo.byId('date_from');
var date_to = dojo.byId('date_to');
try {
date_from.value = dojo.date.locale.format(new Date(), {selector: 'date'});
date_to.value = dojo.date.locale.format(new Date(), {selector: 'date'});
} catch(e) {
var now = new Date();
date_from.value = String(now.getMonth() + "/" + now.getDate() + "/" + now.getFullYear());
date_to.value = String(now.getMonth() + "/" + now.getDate() + "/" + now.getFullYear());
}
dojo.parser.parse();
}
All dialogs have the common date fields. So when I call this dialog the first time, and dojo.parser.parse() is called, it parses the controls on the dialog, but only the first time...after than, no dojo.
Any thoughts?
Thanks, Paul.
You can use
dojo.parser.instantiate([dojo.byId("myDiv")]);
instead of dojo.parser.parse(); Use it on all unparsed objects.
More on this you can find here:
http://livedocs.dojotoolkit.org/dojo/parser
这篇关于dojo.parser.parse只能在第一次被调用时工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!