Yii-bootstrap Tabs Event Handler

I use bootstap tabs and Im trying to download content via ajax, and not install it in PHP. My code is:

<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') )); ?> 

However, I keep getting this error: Uncaught TypeError: Object test has no method 'apply' . I tried to create an object, but it still didn't work. Any ideas?

A quick explanation, JS code generated by the framework:

 <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> 
+4
source share
1 answer

This should work

JavaScript:

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

TbTabs Events (prefixed with 'js:')

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

Source: https://habr.com/ru/post/1435960/


All Articles