dimanche 11 novembre 2018

How to link to other page tab in laravel?

I had a list of tab on view_profil page:

 <div class="panel panel-default">
<ul class="nav nav-pills" id="mytab">
  <li class="active"><a data-toggle="tab" href="#profil">Profil</a></li>
  <li><a id="keluarga-tab" data-toggle="tab" href="#keluarga">Keluarga</a></li>
  <li><a id="kursus-tab" data-toggle="tab" href="#kursus">Kursus</a></li>
  <li><a id="akademik-tab" data-toggle="tab" href="#akademik">Akademik</a></li>
  <li><a id="anugerah-tab" data-toggle="tab" href="#anugerah">Anugerah</a></li>
</ul>

I want to link a button from other page to this page but referring to 'keluarga' tab directly.

I used this code for the button:

<a href="" class="btn btn-warning btn-md">Back</a>

I had tried using a few jquery code and javascript but fail..What is the right javascript/jquery for this purpose?

This is jquery used ;

<script>
var hash = document.location.hash;
if (hash) {
$('.nav-tabs a[href='+hash+']').tab('show');
} 

// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
window.location.hash = e.target.hash;
});
</script>

I had tried numerous script before, this is the latest...

I am using laravel 5 for this application.

But still fail..anyone can help? the error in console:

  jquery-1.12.3.js:1502 Uncaught Error: Syntax error, unrecognized 
  expression: .nav-tabs a[href=#keluarga]
  at Function.Sizzle.error (jquery-1.12.3.js:1502)
  at Sizzle.tokenize (jquery-1.12.3.js:2159)
  at Sizzle.select (jquery-1.12.3.js:2580)
  at Function.Sizzle [as find] (jquery-1.12.3.js:903)
  at jQuery.fn.init.find (jquery-1.12.3.js:2826)
  at new jQuery.fn.init (jquery-1.12.3.js:2949)
  at jQuery (jquery-1.12.3.js:75)
  at 3:2384



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire