php – Yii-bootstrap Tabs事件处理程序

我正在使用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')
)); ?>

但是我一直收到这个错误:
未捕获的TypeError:对象测试没有方法’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>

解决方法:

这应该工作

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐