【问题标题】:Yii-bootstrap Tabs event handlerYii-bootstrap 选项卡事件处理程序
【发布时间】:2012-09-16 02:07:18
【问题描述】:

我正在使用bootstap tabs,我试图通过 ajax 加载内容,而不是在 PHP 中设置它。我的代码:

<script type="text/javascript">
   function test(e){
       console.log(e.target);
       //load ajax stuff here
   }
</script>


<?php
$this->widget('bootstrap.widgets.TbTabs', array(
    'type'=>'tabs',
    'placement'=>'above', // 'above', 'right', 'below' or 'left'
    'tabs'=>array(
        array('label'=>'Ogólne', 'content'=>'Czekaj...', 'active'=>true),
        array('label'=>'Książka adresów', 'content'=>'Czekaj...'),
        array('label'=>'Cośtam', 'content'=>'Czekaj...'),
    ),
    'events'=>array('shown'=>'test')
)); ?>

但是我不断收到此错误: Uncaught TypeError: Object test has no method 'apply'。我尝试创建一个对象,但它仍然不起作用。有什么想法吗?

稍微澄清一下,框架创建的JS代码:

<script type="text/javascript">
/*<![CDATA[*/
jQuery(function($) {
jQuery('a[rel="tooltip"]').tooltip();
jQuery('a[rel="popover"]').popover();
jQuery('#yw0').tab('show');
jQuery('#yw0').on('shown', 'test');
jQuery('#collapse_0').collapse({'parent':false,'toggle':false});
});
/*]]>*/
</script>

【问题讨论】:

    标签: php javascript jquery twitter-bootstrap yii


    【解决方案1】:

    这应该可以工作

    Javascript:

    <script type="text/javascript">
        var test = function(e) {
            console.log(e.target);
            //load ajax stuff here
        }
    </script>
    

    TbTabs 事件(以 'js:' 为前缀)

    <?php
    ...
    'events'=>array('shown'=>'js:test'),
    ....
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多