codeigniter and tab contents -


i have tabs contents functional parts of website.

for instance, in admin area, have tabs [add/delete album][add photo][delete photo]. i'm technically dividing admin area via tabs.

i'm using ajax load content these tabs. tab content area div.

the view inside tab content area uses ajax load stuff. these ajax calls operates inside tab content area.

everything works fine long view inside tab content area stays same or part of changes. when interactions inside tab content area return whole new view, tab content area not show them.

i know happens new view returned not passed tab content area div.

in firebug, can see ajax success function response shows new view returned. not know how pass new view tab content area.

i appreciate if me out in explaining how solved or how contents inside tabs managed in ci.

admintabsview.php  <ul id="admintabs">      <li ><?php echo anchor('#album_adddelete', 'album add/delete'); ?></li>      </ul>    <div id="admintabscontent"></div>  $(document).ready(function(){    $('#admintabs a').on({           click: function (evt){                   evt.preventdefault();                    var page = this.hash.substr(1);                    admintabsajaxcall(page);                }    }); });  function admintabsajaxcall ($data){  $.ajax({     type: "post",     url: "index.php/adminsite_controller/"+ $data + "/",     datatype: "html",     data: $data,     statuscode: {removed}             },     success: admintabcontent          });  function admintabcontent (data){                 $('#admintabscontent').html(data); } 

albumseditdeleteview.php (this view gets loaded tab contentarea div)  <div id="admintabscontent"> <div id="albumlist"> <ul> <li>  <a href="#">asdf</a>  <a class="add" href="http://localhost/myphp/photoalbums/index.php/albums_controller/add_album/301/asdf/1/28/0">[ add ]</a>  <a class="delete" href="http://localhost/myphp/photoalbums/index.php/albums_controller/delete_album/301/asdf/1/28/0">[ delete ]</a> </li> </ul> </div> </div>  $(document).ready(function(){    $('#albumlist').on({             click: function (evt){                   evt.preventdefault();    var $clickedelement = evt.target.tagname; if ($clickedelement == 'a' ){                     var urlarray = url.split('/');           $chosen.albumid     = urlarray[8];     $chosen.albumname   = urlarray[9];     $chosen.lft     = urlarray[10];     $chosen.rgt     = urlarray[11];     $chosen.nodedepth   = urlarray[12];             if ($class == 'add'){                        albumajaxcall($chosen);        }           if ($class == 'delete'){                 deleteajaxcall($chosen);        }                 }                }    }); });   function albumajaxcall($data){ $.ajax({     type: "post",     url: "index.php/adminsite_controller/add_album/",     datatype: "json",     data: $data,     statuscode: {removed}             },     success: admintabcontent });  }  function admintabcontent(data){          $('#admintabscontent').html(data); } 

//heres view file has replace original view inside  //tabcontent area //addnode_view.php     <?php echo form_open('albums_controller/update_albumset');?>                                         <input type="text" name="newalbum" id="newalbum" value=""/>                      <input type="submit" name="submit" value="submit" />             <?php echo form_close();?>     <?php    //heres controller function function add_album(){                $leveldata ['albumid']      = $this->input->post('albumid');     <!-- removed-->      $leveldata ['main_content'] = 'addnode_view';        $this->load->view('includes/template', $leveldata); }    //and heres controller method loads   //the original page (albumseditdeleteview.php) - original view   //that gets loaded tab- stuck when view   //has **totally** replaced through links in view)  function album_adddelete(){     $allnodes ['myalbumlist'] = $this->albums_model->get_albumlist();     echo $this->load->view('albumseditdelete_view', $allnodes);  } 

thanx in advance.

basically need load whatever new view youll putting in tab in controller function(adminsite_controller/whatever function) handling ajax.

this echo out view file, viewed success variable of ajax function.

so have success part of ajax

success:function(msg){admintabcontent(msg);} 

and in controller in codeigniter you'll load view standard way, since loading piece of page may need create new view file thats div there. data gathering same way if wasn't ajax.

$data['some_data'] = $this->some_model->some_function(); $this->load->view('someview', $data); 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -