jquery - Codeigniter View with controller within View (with a Controller) when loading the 2nd view the 1st view data are erased -


second view

<script type="text/javascript">  var globalvariables = {     'csrftoken'     : <?php echo json_encode($this->security->get_csrf_hash()); ?>,     'baseurl'       : <?php echo '"' . $base_url . '"'; ?>,     'dateformat'    : <?php echo json_encode($date_format); ?>,     'services'      : <?php echo json_encode($services); ?>,     'categories'    : <?php echo json_encode($categories); ?>,     'user'          : {         'id'        : <?php echo $user_id; ?>,         'email'     : <?php echo '"' . $user_email . '"'; ?>,         'role_slug' : <?php echo '"' . $role_slug . '"'; ?>,         'privileges': <?php echo json_encode($privileges); ?>     }   };    $(document).ready(function() {     backendservices.initialize(true);   }); </script>   <div>some contenent</div> 

so view integrate within view

first view

<script type="text/javascript"> var globalvariables = {     'csrftoken'     : <?php echo json_encode($this->security->get_csrf_hash()); ?>,     'baseurl'       : <?php echo '"' . $base_url . '"'; ?>,     'dateformat'    : <?php echo json_encode($date_format); ?>,     'userslug'      : <?php echo '"' . $role_slug . '"'; ?>,     'settings'      : {         'system'    : <?php echo json_encode($system_settings); ?>,         'user'      : <?php echo json_encode($user_settings); ?>     },     'user'          : {         'id'        : <?php echo $user_id; ?>,         'email'     : <?php echo '"' . $user_email . '"'; ?>,         'role_slug' : <?php echo '"' . $role_slug . '"'; ?>,         'privileges': <?php echo json_encode($privileges); ?>     } };    $(document).ready(function() {     backendsettings.initialize(true);  }); </script>  <div>sidebar..   ...        <div id="#loading-view" > tab in side bar</div>  </div> 

i found similar case mine views without controller tried in first view controller (the view have side bar)

 $('.tab').click(function() {    $('#loading').load(globalvariables.baseurl + '/index.php/backend/services'); 

but when loading second view in loading div data of other tab erased or . know problem in .ready() ajax function because when read it, load entire view or when comment ready() function in second view css apear without data .

so please has had problem ?

jquery element.load() replace content of element every time. load view inside parent view need load content child div inside parent view.

html

<div id="parentview">    <div id="childview"></div> </div> 

javascript

$('.tab').click(function() {        $('#parentview').load(globalvariables.baseurl + '/index.php/backend/services');        $('#childview').load(globalvariables.baseurl + '/index.php/backend/services');     }); 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -