Categories | Question details Back To List | ||||||||
Problem upgrading to 2.5 Since upgrading to 2.5 my own javascript functions appear to be undefined after the layout object is created even though they are there. A simplified snippet of code from the body: <script type="text/javascript"> // GLOBAL VARIABLES var dhxLayoutRight; // LAYOUT INITIALISATION dhtmlxEvent(window,"load",doInitLayout); function doInitLayout(){ alert('a'); dhxLayoutRight = new dhtmlXLayoutObject(parent.dhxLayout.cells("b"), "2E", "dhx_skyblue"); // Alternative examples to document.body are "layout_jobs" and parent.dhxLayout.cells("b") dhxLayoutRight.cells("a").setText('<?php echo $params['text_header'] ?>'); alert('b'); testa(); dhxLayoutRight.cells("b").collapse(); dhxLayoutRight.cells("b").setText("<?php echo $params['item_header'] ?>"); } function testa(){ alert('test'); } </script> The layout is rendered correctly if I remove the alerts and do not call my own Javascript functions. alert('a'); works alert('b'); gives the following error: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMWindowInternal.alert]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://10.1.1.11/jobtracker_dev/frontend_dev.php/item :: doInitLayout :: line 91" data: no] http://10.1.1.11/jobtracker_dev/frontend_dev.php/item Line 91 If I comment out alert('b'); then the layout does not render at all and I get the following error: this.base.offsetParent is null http://10.1.1.11/jobtracker_dev/js/dhtmlx/codebase/dhtmlxlayout.js Line 40 Note that parent.dhxLayout is created in the head section and works fine. Due to the way I need to mix php and javascript with the framework I am using I can't put the above code in the head section and besides it worked perfectly before the upgrade. Answer posted by Alex (support) on Sep 08, 2009 03:00 Please, check that all necessary js and css libraries are included. The sample is dhtmlxLayout/samples/01_init/01_object.html ( http://www.dhtmlx.com/docs/products/dhtmlxLayout/samples/01_init/01_object.html ) Answer posted on Sep 08, 2009 03:52 Thanks. I'd already looed at the sample. These are the js and css files: <link rel="stylesheet" type="text/css" href="<?php echo $css_path ?>main.css" media="screen" /> <link rel="stylesheet" type="text/css" href="<?php echo $dhtmlx_codebase_path ?>dhtmlxlayout.css"> <link rel="stylesheet" type="text/css" href="<?php echo $dhtmlx_codebase_path ?>skins/dhtmlxlayout_dhx_skyblue.css"> <link rel="stylesheet" type="text/css" href="<?php echo $dhtmlx_codebase_path ?>dhtmlxwindows.css"> <link rel="stylesheet" type="text/css" href="<?php echo $dhtmlx_codebase_path ?>skins/dhtmlxwindows_dhx_skyblue.css"> <link rel="stylesheet" type="text/css" href="<?php echo $dhtmlx_codebase_path ?>skins/dhtmlxtoolbar_dhx_skyblue.css"> <link rel="stylesheet" type="text/css" href="<?php echo $dhtmlx_codebase_path ?>skins/dhtmlxaccordion_dhx_skyblue.css"> <link rel="stylesheet" type="text/css" href="<?php echo $dhtmlx_codebase_path ?>dhtmlxgrid.css" /> <link rel="stylesheet" type="text/css" href="<?php echo $dhtmlx_codebase_path ?>skins/dhtmlxgrid_dhx_skyblue.css"> <link rel="stylesheet" type="text/css" href="<?php echo $dhtmlx_codebase_path ?>dhtmlxtabbar.css" /> <?php use_javascript('jquery-1.3.2.min.js'); use_javascript('json2.js'); use_javascript('dhtmlx/codebase/dhtmlxcommon.js'); use_javascript('dhtmlx/codebase/dhtmlxlayout.js'); use_javascript('dhtmlx/codebase/dhtmlxcontainer.js'); use_javascript('dhtmlx/codebase/dhtmlxgrid.js'); use_javascript('dhtmlx/codebase/dhtmlxgridcell.js'); //use_javascript('dhtmlx/codebase/ext/dhtmlxgrid_json.js'); use_javascript('dhtmlx/codebase/ext/dhtmlxgrid_srnd.js'); use_javascript('dhtmlx/codebase/ext/dhtmlxgrid_filter.js'); // use_javascript('dhtmlx/codebase/ext/dhtmlxgrid_hmenu.js'); use_javascript('dhtmlx/codebase/dhtmlxtabbar.js'); use_javascript('dhtmlx/codebase/ext/dhtmlxtabbar_wins.js'); // dhtmlxWindows ?> <?php use_javascript('dhtmlx/codebase/dhtmlxwindows.js'); if (is_object($guardUser)) { // dhtmlxToolbar use_javascript('dhtmlx/codebase/ext/dhtmlxwindows_wtb.js'); use_javascript('dhtmlx/codebase/dhtmlxtoolbar.js'); ?> <?php // dhtmlxStatusbar use_javascript('dhtmlx/codebase/ext/dhtmlxwindows_sb.js'); use_javascript('dhtmlx/codebase/dhtmlxaccordion.js'); ?> <?php use_javascript('utils/dhtmlxutils.js'); } include_javascripts() ; Answer posted by Alex (support) on Sep 08, 2009 04:26 The issue wasn't reproduced locally. The sample is attached Attachments (1)
Answer posted by Stephen Neander on Sep 11, 2009 03:46 Thanks - The sample works but that doesn't help me. I presume that when I get the error saying that my own function isn't defined it is because of an error further up on the page which is not being reported. I noticed that in v2, dhxLayoutRight is wrapped in an iframe but in v2.5 it is not. Why would this be and how can I control it? Answer posted by Stephen Neander on Sep 11, 2009 04:58 I got the inner iframe back by changing: dhxLayoutRight = new dhtmlXLayoutObject(parent.dhxLayout.cells("b"), "<?php echo $hasChildView ? "2E" : "1C" ?>", "dhx_skyblue"); to dhxLayoutRight = new dhtmlXLayoutObject(document.body, "<?php echo $hasChildView ? "2E" : "1C" ?>", "dhx_skyblue"); and now it all magically works. |