Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Tabs Using foreach On Opencart

I want change tabs on opencart (admin view) with twitter bootstrap 3.0, the code following :

catalog_form.tpl

 <ul id="myTab" class="nav nav-tabs">
   <li class="active"><a href="#tab-general" data-toggle="tab"><?php echo $tab_general; ?></a></li>
   <li class=""><a href="#tab-data" data-toggle="tab"><?php echo $tab_data; ?></a></li>
   <li class=""><a href="#tab-design" data-toggle="tab"><?php echo $tab_design; ?></a></li>
</ul>

<div id="myTabContent" class="tab-content">
  <div id="tab-general" class="tab-pane fade active in"> 

  <ul id="languages" class="nav nav-tabs">
    <?php $i = 0; ?>
      <?php foreach ($languages as $language) { ?>
         <li class="<?php if ($i == 0) { echo 'active'; } ?>"> 
            <a href="#language<?php echo $language['language_id']; ?>" data-toggle="tab"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a>
        </li>
      <?php $i++; } ?>
  </ul>
  <div id="Mylanguages" class="tab-content">
    <?php $a = 0; ?>
    <?php foreach ($languages as $language) { ?>
      <div id="language<?php echo $language['language_id']; ?>" class="tab-pane fade <?php if ($a == 0) { echo 'active'; } ?> in">
      <?php echo $language['language_content']; ?>
      </div>
    <?php $a++; } ?> 
  </div>

  </div>
  <div id="tab-data" class="tab-pane fade">
   ...
  </div>
  <div id="tab-design" class="tab-pane fade">
   ...
  </div>
</div>

Parent tabs (tab-general, tab-data, tab-design) without foreach work perfectly

First reload, language 1 is active tab

enter image description here

When click language 2's tab

  • link #language2 tag have selected class
  • div tag with id language2 have display block but not have active class
  • language 1 li still have active class but language 2 li have not active class.

enter image description here

When I try copy html (via inspect element) and make on jsfiddle (modify content not html tag) it's works perfectly. Jsfiddle

like image 359
GeekToL Avatar asked Sep 19 '13 08:09

GeekToL


1 Answers

Problem Solved

Just remove default jquery tabs on opencart

<script type="text/javascript"><!--
$('#tabs a').tabs(); 
$('#languages a').tabs();
//--></script> 

This script will you see on template file using language tabs admin/view/template/xxx/xxxx_form.tpl

like image 126
GeekToL Avatar answered Nov 15 '22 14:11

GeekToL