vendredi 10 juin 2016

Yii refresh Tab data on Tab Active


I am working on Yii application and using Tabs to show chart and data. my code is as bellow

<ul class="nav nav-tabs">
           <li class="active">
            <a href="#tab-graph” data-toggle="tab">
             <?php echo Yii::t('li', ‘Graph’);?>
               </a>
             </li>
              <li>
               <a href="#tab-overview" data-toggle="tab">
                 <?php echo Yii::t('li', ‘Overview');?>
                  </a>
                    </li>
              </ul>


<div class="tab-content">
      <div class="tab-pane active" id="tab-graph">
  <?php
  $this->renderPartial(‘graph/graph’);
  ?>
</div>
<div class="tab-pane" id="tab-overview">
  <div> here is status</div>
  <div> 10%</div>
</div>

</div>

in first tabe i am renderPartial the file which show YII graph, but the issue is when i click on next tab and come back to first tab, graph dissappear.

i think YII graph did't like tabs and hide.

how to make the graph active on first tab when click away and come back ? or i want to refresh the tab and render again to show graph.

<script>
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  var target = $(e.target).attr("href")

  if(target=="#tab-graph"){
    //alert(target);
    location.reload();
  }
});
</script>

i have done this uing jquery but this refresh all page, but i only need to show graph or only refresh the tab not all page.

Thanks


Aucun commentaire:

Enregistrer un commentaire