i have this code.
function index(){
$this->load->helper('url');
$this->load->view('EIM/home');
$this->loadGraphs();
}
but it executes loadGraphs first. I really have no idea why. Please help me. I'm having a hard time fixing my codes. thanks :)
here is my loadGraphs function:
`function loadGraphs(){ $this->load->helper('url'); $ctr=0; $base_url = base_url(); $xml=new DOMDocument; $xml->load("".$base_url."assets/EIM/xml/defaultChart.xml"); $module_names=$xml->getElementsByTagName("name"); $len_modules=$module_names->length; $ctr_module=0; while($ctr_moduleitem($ctr_module)->getElementsByTagName("report"); $len_reports=$reports->length; $ctr_report=0; while($ctr_reportitem($ctr_module)->getAttribute("value"); $title=$reports->item($ctr_report)->getElementsByTagName("title")->item(0)->nodeValue; $dashboard_selected=$reports->item($ctr_report)->getAttribute("id"); if($dashboard_selected=="dashboard"){ echo " $title $module"; ?> var parameters=eval(getArray($title,$module));?>) item($ctr_report)->getElementsByTagName("charts")->item(0)->getAttribute("value"); $defaultChart=$reports->item($ctr_report)->getElementsByTagName("charts")->item(0)->getAttribute("value"); echo "$defaultChart"; $charts=$reports->item($ctr_report)->getElementsByTagName("charts")->item(0)->getElementsByTagName("chart"); $len_charts=$charts->length; $ctr_chart=0; while($ctr_chartitem($ctr_chart)->nodeValue; echo " ";
$ctr_chart++;
}
echo"
<input type='submit' value='Set Chart as Default' onClick='set_default_chart('chart$ctr',$ctr_module,$ctr_report)'/>
";
echo "
<button class='btn btn-box-right' data-toggle='collapse' data-target='#container".$ctr."'>
<i class='icon-reorder'></i>
</button>
</div>
<div class='box-content box-list collapse in'>
<div id='container".$ctr."' style='min-width: 310px; height: 400px; margin: 0 auto'></div>
</div>
</div>
</div>
";
$ctr++;
}
$ctr_report++;
}
$ctr_module++;
}
echo "<label id='containers' value='$ctr'></label></div>";
}`
its kinda long but what it does is that it makes the containers ready and my java script is there to load and completely show the graphs. its in the document.ready function. it is possible that it prioritizes the codes that have function before loading the view?
loadGraphs
code – knizhnikov