attachURL and .getFrame() HELP!

OK! This is blowing my mind…I have attached a URL to a layout object, no problems until I try to access one of the elements by using getFrame(). I have read all the documentation and went through about 15 forum posts and everything has failed.

iframeObject = var.projectLayout.cells("a").getFrame();
iframe = iframeObject.contentWindow;
iframe.document.getElementById("task_grid").innerHTML = "hi!";

This throws and error: Cannot call method ‘getElementById’ of undefined.

Typed into chrome console:

iframe.document.getElementById("task_grid");

RETURNS THE DIV!!!

How is it undefined when chrome sees it???

My initial hunch is maybe the page loads slower than the js executes? If that is the case, how can I make it wait for the page to load before looking for the divs? AJAX is out of the question, as when I set the ajax option to true I get even more errors.

Hello
Could you provide us both your html files?

app.projectLayout.cells("a").attachURL("./php/projects_page.php?pid="+id);
iframeObject = fmg.projectLayout.cells("a").getFrame();
iframe = iframeObject.contentWindow;
iframe.document.getElementById("task_grid").innerHTML = "hi!";

app.projectTaskGridLayout = new dhtmlXLayoutObject(iframe.contentWindow.document.getElementById("task_grid"),"1C");
app.projectTaskGrid = app.projectTaskGridLayout.items[0].attachGrid();
app.projectTaskGrid.setImagePath("./resources/css/imgs/");
app.projectTaskGrid.setHeader("Name, Test, Test, Test");
app.projectTaskGrid.init();
app.projectTaskGrid.load("./php/project_task_grid.php?pid="+id);

The projects_page.php is just a php file with a bunch of html and php in it. But is has the div labeled task_grid.

sorry fmg.projectLayout.cells(“a”).getFrame(); is app.projectLayout.cells(“a”).getFrame();

There is not enough data. Send me you COMPLETED DEMO in PM or if you use the PRO Edition and you have active support subscribtion, please create a ticket in the online support system and attach completed demo there.
docs.dhtmlx.com/doku.php?id=othe … leted_demo

I think it’s just a timing issue; the content isn’t there immediately when you attach the URL. Try putting your access to the cell’s content inside the onContentLoaded handler. This worked for me:

app.projectLayout.attachEvent("onContentLoaded",function(cell) { // test getting the title from the included content if (cell == "a") { iframeObject = this.cells("a").getFrame(); iframe = iframeObject.contentWindow; iframe.document.getElementById("task_grid").innerHTML = "hi!"; } });