I’m using a “3T” layout in a window which has a grid attached to the first and second cell.
In the third one, I want to attach an object declared in my html part.
But nothing appears in the cell … somebody has an idea of the problem ?
hore is the code :
<div id="myDiv">hello</div>
<script>
var dhxLayout = parent.dhxWins.window("view_ticket").attachLayout("3T");
var grid1 = dhxLayout.cells("a").attachGrid(); // OK
[...]
grid1.init();
var grid2 = dhxLayout.cells("b").attachGrid(); // OK
[...]
grid2.init();
dhxLayout.cells("c").attachObject("myDiv"); // KO
</script>
it seems the problem is the div element isn’t loaded in the DOM when the attachObject method is called (I tried to get the DOM object with a document.getElementById … and it fails).
I also thought to embed the javascript code in a function called when the content is fully loaded in the window (see the code below), but the callback is never called (I haven’t any widget in the window … just the “div’s content”) … any idea ?
<div id="myDiv">hello</div>
<script>
parent.dhxWins.window("view_ticket").attachEvent("OnContentLoaded", function() {
var dhxLayout = parent.dhxWins.window("view_ticket").attachLayout("3T");
var grid1 = dhxLayout.cells("a").attachGrid();
[...]
grid1.init();
var grid2 = dhxLayout.cells("b").attachGrid();
[...]
grid2.init();
dhxLayout.cells("c").attachObject("myDiv");
});
</script>
attachURL(url,true) loads content using Ajax and places it as innerHTML .
So,
hello
became the content of the window. When you call var dhxLayout = dhxWins.window(“test”).attachLayout(“3T”);, the layout replaces this div (div is removed).