简体   繁体   English

返回保存为javascript变量的html

[英]returning html saved as a javascript variable

I am working with Dojo data grid row expansion. 我正在使用Dojo数据网格行扩展。 Example here. 这里的例子。

I am trying to put another grid inside the part that expands. 我试图在扩展的部分内放置另一个网格。 Here, I create the grid container and append the grid to it 在这里,我创建了网格容器并将网格附加到其中

gridDiv = document.createElement('div');
gridDiv.setAttribute('class','blah');
gridDiv.appendChild(grid2.domNode);

Later on, I am trying to print that div out on the page by returning gridDiv . 稍后,我尝试通过返回gridDiv在页面上打印该div。

return gridDiv; //gives me "[object HTMLDivElement]" in the expanded section
return gridDiv.HTML; //gives me "..." in the expanded section
return String(gridDiv); //gives me "[object HTMLDivElement]" in the expanded section

How do I get it to actually put the div element with the grid inside on the page? 如何获得将div元素与网格实际放置在页面上的信息? I can not use the jQuery library, but I can use the Dojo library. 我不能使用jQuery库,但可以使用Dojo库。

Thanks for any help you can give! 谢谢你提供的所有帮助! I feel like I'm missing something very obvious... 我觉得我想念的东西很明显...

/ BREAKTHROUGH / I used gridDiv.innerHTML as a variable and returned THAT in the code. / 突破 /我使用gridDiv.innerHTML作为变量,并在代码中返回了THAT。 However, now it is printing out the HTML in plain text... I've got to figure out why it is not parsing now. 但是,现在它正在以纯文本格式输出HTML……我必须弄清楚为什么现在不解析它​​。

Try using dojo.place 尝试使用dojo.place

// Dojo < 1.7
dojo.place(node, refNode, pos);

http://dojotoolkit.org/reference-guide/1.7/dojo/place.html http://dojotoolkit.org/reference-guide/1.7/dojo/place.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM