代码之家  ›  专栏  ›  技术社区  ›  Robus

Yii引导程序选项卡事件处理程序

  •  4
  • Robus  · 技术社区  · 12 年前

    我正在使用 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>
    
    1 回复  |  直到 12 年前
        1
  •  4
  •   SuVeRa    12 年前

    这应该有效

    Java脚本:

    <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'),
    ....
    ?>