dojo.parser.parse只能在第一次被调用时工作 [英] dojo.parser.parse only working first time it's called

查看:70
本文介绍了dojo.parser.parse只能在第一次被调用时工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,当用户点击某些报告工具的链接时,它首先要求他们输入一些报告参数。我使用AJAX作为一个表单获取参数对话框,基于链接的ID。每个对话框都有一些dojo控件,所以当对话框出现时,我需要解析它们,因为它不是页面的一部分。



调用第一个对话框工作正常,但后续调用对话框无法解析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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆