[eluser]Gilles_T[/eluser]
nuwanda,
I do the refresh the panel with an javascript reload, and that is clean (I guess). But for the initial display, I directly call the function in the controller that generates the HTML. This is where the view calls the controller.
To be more specific, I have a controller dashboard.php that contains the index function and a set of couple of functions panel_x_view and panel_x_get_view (meant to display the X panels) :
-> panel_x_view generates the html for the particular information panel ($d)
Code:
return $this->load->view('panel_x_view',$d,true);
-> index function calls the main view to which the html generated above is passed :
Code:
$this->load->view('dash_main_panel_view',array(
'panel_x_html' => $this->panel_x_view($data),
'panel_y_html' => $this->panel_y_view($data),
'panel_z_html' => $this->panel_z_view($data),
'panel_t_html' => $this->panel_t_view($data)
));
-> panel_x_get_view is just a page wrapper that gets make a page header, calls the html of panel_x_view and make a footer
-> dashboard main window will call the panel_x_get_views the following way :
Code:
<?php if($panel_x_html != null):?>
<!-- script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#load_panel_x').load('<?=site_url()?>/dashboard/panel_x_get_view').fadeIn("slow");
}, <?=TBORD_REFRESH+80?>); // 80 is different for each panel to avoid simultaneous calls
<!-- /script>
<div id="load_panel_x" class="dashboard_panel"><?=$panel_x_html?></div>
<?php endif;?>
The problem is, if I don't call the display, I have to wait until the page refresh...
The core question is : Is it technically risky to call a controller from a view ? May it generate some bad behavior at server level or at the user's session level ?
Regards