problem with using refresh() on an Active.HTML.DIV?

I have the following scenario that is not doing what I would expect it to. I have decided to do all of my page generation through the use of Active.HTML objects. I create a page one, then via scripts from the server I alter portions of the page to display new information or change object properties. Here is some code that you can try and load and see if you get the same results. Basically, one the refresh() method is called, things go south. Any thoughts as to how I can change to code to get the desired results or is there a bug that there is a fix too?


<SCRIPT type="Text/javascript" src="grid.js" ></SCRIPT>
<body style="padding:0;margin:0">
<script type="text/javascript">
div1 = new Active.HTML.DIV;
div1.setStyle("background-color", "blue");
div1.setStyle("position", "absolute");
div1.setStyle("width", 200);
div1.setStyle("height", 200);

// now lets assume other things happen here, over time, and then
// later we want to add a div to div1
// everything I do is on the fly and the page
// never gets 'refreshed' it just gets pieces of
// it changed via scripts

div2 = new Active.HTML.DIV;
div2.setStyle("width", 50);
div2.setStyle("height", 50);
div2.setStyle("position", "absolute");
div2.setStyle("background-color", "red");
div1.setContent("html", div2.toString()); // have also used just div2 but got the same results
// if there is a better, more correct way to
// add one Active object to another let me know
alert(div1); // you get the exact result you would expect to get
div1.refesh(); // to display the first DIV with it's new div inside
// note that it doesn't work
alert(div1); // note that this alert never happens, what happened to
// the script?
Jim Hunter
November 16,
Jim, it seems that you just have typing mistake:
div1.refesh(); instead of div1.refresh(); otherwise the script works fine.
Alex (ActiveWidgets)
November 16,
I know I'm going blind, I guess now I'm going stupid too. I looked over the code many times and didn't see it. Thanks for the heads up.
Jim Hunter
November 16,
I see another potential problem. Again, there might be a different way to do what I am trying to do. Here is the scenario:

create div1
create div2 and parent it with div1
create div3 and parent it with div2

so now I have something like:
<div id=1><div id=2><div id=3></div></div></div>

if I now try and add another div (div4) to div1 I loose div3. I get something like:
<div id=1><div id=2></div><div id=4></div></div>

I think that when I am adding div4 and I use a line like:

div1.setContent("html", div1.getContent("html") + div4);

the result of div1.getContent("html") is not correct. It is missing div3 and the id for div2 is listed as div1/html instead of div2 which I have it set to. So it looks like the bug is in getContent("html"). Is there another way to return ALL of the "innerHTML" of the div, other then getContent("html"), that I am missing here? how would someone else code the scenario that I have presented here and make it work?

Thanks Alex for your help so far. I think once I get over this hurdle I can start to write some test cases for regression testing (future version compatibility) and be on my way.
Jim Hunter
November 16,
There is a work around that I just found. In place of .getContent("html") you can use .element().innerHTML and the problem goes away. I am able to go as deep as I want on parenting and everything works well. This fix was tested on IE, FireFox, Mozilla and Opera (I know that AW in general doesn't work well in Opera).
I think it would be 'cleaner' to stick with the built in methods, but at this point I am happy there is a solution.
Jim Hunter
November 16,

This topic is archived.

See also:

Back to support forum