Welcome Guest, Not a member yet? Register   Sign In
How to load specific view part?
#1

[eluser]rafi_ccj[/eluser]
i have a view file named index. where i call to load different view files such as header, footer, left content, middle content, right content. from controller i send an array named $result['body'], which is the middle content in the view.
now i want to refresh only the middle content rather than the all view files in the index. is it possible in codeigniter?

below is my index file code.
Code:
<?php $this->load->view('gw/gw_main/template/header'); ?>
<?php $this->load->view('gw/gw_main/template/middle'); ?>//i want to refresh only this part.
<?php $this->load->view('gw/gw_main/template/bottom'); ?>
<?php $this->load->view('gw/gw_main/template/footer'); ?>
#2

[eluser]Otemu[/eluser]
You could use Ajax to refresh the view, not sure if your familiar with jQuery however check the load method here

Another method would be to use an iframe and have that particular view set to a refresh rate.
#3

[eluser]boltsabre[/eluser]
As Otemu alluded to, this cannot be done with standard PHP/html.

When a user requests a page a few things happen:
- User clicks a link/page on your site
- The browser gets this url, and passes it to your server
- The server runs the request to get the details of that page (this is where codeigniter starts, your controller runs, pulls any data it needs to from a model, and passes variables to your views via the $data variable you pass to them. The views are constructed, and then your server passes the html from it back to the browser of the user.

So you can set it's a very "set in stone" process:
Browser request page, server makes it, passes back to browser for display.

To dynamically re/load new content into the browser without a page refresh you need to make use of one of the two technologies mentioned by Otemu. They basically go to the server and say, "please give me this little bit of information, but without refreshing the page". When it comes back, it will either replace existing content, or just be inserted somewhere (depending on how you've set it up).
#4

[eluser]rafi_ccj[/eluser]
i know these ..... but someone told me that it is possible in codeigniter to load specific view part without whole page load, (codeigniters' jquery modification)....i have searched about it on net but could not find anything about that...that is why i was asking here.....by the way thanks for you all peoples' effrt.....
#5

[eluser]CroNiX[/eluser]
They misunderstood or were wrong.

The only way CI can load a "view partial" is by
Code:
<?php $this->load->view('gw/gw_main/template/middle'); ?>
And CI doesn't know if its a partial or not; it only knows it's a view.

So, you'd need an ajax function that calls some CI method that returns only that view, and in the callback of the ajax function replace the html on the page with the returned html from your function.

There is nothing in CI that does this "automatically"
#6

[eluser]rafi_ccj[/eluser]
thanks....yeah i was trying to do that with jquery/ajax way.......thanks you for your explanation, it will help me!




Theme © iAndrew 2016 - Forum software by © MyBB