Reputation: 387
I am using codeigniter for my website.i had a situation to load a view within another view.how could i do this.Codeigniter follows the MVC pattern so we cannot directly load the another view without the help of controller. here is my menuview page
<table align="center" width="200" border="0" style="margin-left:160px">
<tr align="left">
<td ><input type="radio" id="R1" name="R1" value="1" />PieChart</td>
<td><input type="radio" id="R1" name="R1" value="2" />BarChart</td></tr></table>
<div class="clear"></div>
<div id="chart_div"></div>
where the div with id "chart_div" here i want to load another view called chart.php belongs to view.how could i load the chart.php view page when user select radio button.
Upvotes: 0
Views: 3565
Reputation: 82028
CI lets you return a view as a variable. It is not very common, but you can find information at the very bottom of the docs. You're basically going to need to do something like this:
$charDiv = $this->load->view( 'chart', $charDivVars, TRUE );
$this->load->view( 'menuview', array( 'chart_div' => $chartDiv ) );
Then, in your view:
<div id="chart_div"><?php echo $chart_div; ?></div>
Upvotes: 1