# Tab By Ajax

Loading tab with ajax thru URL hash (e.g: [https://www.website.com/page#tab1](https://www.website.com/page#tab1)) will have issue where the `shown.bs.tab` is not triggered. Bootstrap3 do not handle this automatically for you.

You will need to do this manually like the code below. Do notice your has trigger must come after your `on event` code.

```php
<?php Yii::app()->clientScript->registerScript(
	'js-book-view',
<<<EOD
$('a[href="#book-info"]').on('shown.bs.tab', function (e) {
	$( "#latest-story" ).load( $('#latest-story').data('url'));
});
$('a[href="#book-index"]').on('shown.bs.tab', function (e) {
	$( "#book-indexes" ).load( $('#book-indexes').data('url'));
});
$('a[href="#book-donate"]').on('shown.bs.tab', function (e) {
	$( "#book-donates" ).load( $('#book-donates').data('url'));
});
$('a[href="#book-stat"]').on('shown.bs.tab', function (e) {
	updateNovelMonthlyStats('$model->id');	setInterval(function() {updateNovelMonthlyStats('$model->id');}, 300000);
});

var hash = window.location.hash;
if (hash) {
	$('.nav-tabs a[href="' + hash + '"]').trigger("shown.bs.tab");
}

EOD
); ?>
```
