开发者

Hiding jQuery Tabs

开发者 https://www.devze.com 2023-03-22 15:17 出处:网络
Is there a way to hide an empty jQuery tab? Specifically I am using Yii\'s CJuiTabs and pulling the tab content from a db.

Is there a way to hide an empty jQuery tab?

Specifically I am using Yii's CJuiTabs and pulling the tab content from a db.

If that content does not exist in the db I do not want a tab displayed at all for that. Can this be done?

Including CJuiTabs in Yii:

$this->widget('zii.widgets.jui.CJuiTabs', array(
    'tabs'=>array(
     开发者_StackOverflow中文版   'StaticTab 1'=>'Content for tab 1',
        'StaticTab 2'=>array('content'=>'Content for tab 2', 'id'=>'tab2'),
        // panel 3 contains the content rendered by a partial view
        'AjaxTab'=>array('ajax'=>$ajaxUrl),
    ),
    // additional javascript options for the tabs plugin
    'options'=>array(
        'collapsible'=>true,
    ),
));


For the stuff generated in PHP

foreach ($dbContents as $id => $content) {
  if (!$content) continue;
  $tabs[] = Array('id' => 'tab-'.$id, 'content' => $content)
}

$this->widget(....., array('tabs'=>$tabs));

PS: Written on my mobile, Code could be a bit more sophisticated :)

0

精彩评论

暂无评论...
验证码 换一张
取 消