Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Kris on Aug 10, 2009 09:07
open dhtmlx forum
How to use execScript with loading content via ajax

Hi,

I am using dhtmlxLayout and I am loading content via ajax as follows

dhxLayout.cells("a").window.attachURL('msOpenX.asp',true);

Page: msOpenX.asp contains some script in <script></script> tags which I want executed when page is loaded via ajax.

I am not sure how to use execScript with this. Any help would be appreciated.

Thanks,
Kris

Answer posted by Alex (support) on Aug 10, 2009 09:38

Hello, 

layout doesn't executes the script that is defined in the page loaded by ajax. 

It is better to call script from the main page:

layout.parentDhxWins.attachEvent("onContentLoaded",function(win){

if(win==dhxLayout.cells("a").window) callScript();

});

Answer posted by kris on Aug 10, 2009 09:54
It does not seem to work

This is simple code inside loadLayout.asp

     <script>
        var dhxLayout = new dhtmlXLayoutObject("parentId", "3L", "dhx_blue");
        dhxLayout.cells("a").window.attachURL('msOpenX.asp',true);
       
      

               dhxLayout.parentDhxWins.attachEvent("onContentLoaded",function(win){

                      if(win==dhxLayout.cells("a").window)  loadAlert();

                  });


    </script>

msOpenX.asp contains the following script tags with some html content as an example

html content and script tags are loaded but script is not executed.

<script>
function loadAlert(){
window.alert('Content loaded and script executed');
}
</script>
Answer posted by Alex (support) on Aug 11, 2009 02:16

loadAlert() function should be define in the page with layout - all content of "msOpenX.asp" is added as innerHTML.

But there is also and issue in the approach that we have provided before. There should be dhxWins instead of parentDhxWins. and this function should be included before  attachURL method to be called.

function loadAlert(){
  window.alert('Content loaded and script executed');
}

dhxLayout.dhxWins.attachEvent("onContentLoaded",function(win){
  if(win==dhxLayout.cells("a").window) loadAlert();
});

dhxLayout.cells("a").window.attachURL('msOpenX.asp',true);