Hi,
I’ve a tabs widget with 4 gridview, one in tab Inbox, one in tab Outbox and two in tab Archive which has a dropdown.
echo Tabs::widget([
'id' => 'tab',
'items' => [
[
'label' => 'Inbox',
'options' => ['id' => 'inbox'],
'content' => /* gridview n.1*/,
],
[
'label' => 'Outbox',
'options' => ['id' => 'outbox'],
'content' => /* gridview n.2*/,
],
[
'label' => 'Archive',
'items' => [
[
'label' => 'To Me',
'options' => ['id' => 'to_me'],
'content' => /* gridview n.3*/,
],
[
'label' => 'From Me',
'options' => ['id' => 'from_me'],
'content' => /* gridview n.4*/ ,
],
],
],
],
]);
If I’m in tab n.2 and I search something in the gridview search, the widget refresh on tab 1. If I move manually to tab 2 the results are shown. Same behaviour if I use navigation of gridview to show page n.2 of gridview (in this case the url change to myview?page=2).
Is there a way to remember active tab ? I’ve tried this code but it doesn’t work.
<script>
$(document).ready(function() {
if (location.hash.length) {
$('[data-toggle="tab"], [data-toggle="pill"]').filter('[href="' + location.hash + '"]').tab('show');
}
}
$(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
location.hash = e.target.hash;
});
</script>
Thank you