How to link to other page tab in laravel?









up vote
0
down vote

favorite
1












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=" url('/view_profil/' . $valueItemregistrationkeluarga->ItemRegistrationID.'#keluarga') " 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 have tried your solutions without tabs:



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


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


I also tried this code:



Try1:



 // Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#'))
$('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');


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


Try 2:
var openTab = $(location.hash).filter(".tab_content");



 if(openTab.length)
$("a[href='"+location.hash+"']").click();



Try 3:



 <script type="text/javascript">
(function activateTabFromHash() if (location.hash) var tabLink = document.querySelector('a[href="' + location.hash + '"]'); if (!tabLink) return false; tabLink.click(); if (location.hash)
setTimeout(function()
window.scrollTo(0, 0);
, 1);
)();
</script>


I am using laravel 5 for this application.



The button can link to the page but it doesn't activate the specified tab.










share|improve this question























  • Try putting the href value in quotation marks in the jQuery selector, e.g. $('.nav-tabs a[href="'+hash+'"]').
    – Delena Malan
    Nov 13 at 13:19










  • sorry, i don't understand. Can you answer and explain a little bit..If it is working, I can accept your answer. Thanks
    – joun
    Nov 14 at 1:38














up vote
0
down vote

favorite
1












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=" url('/view_profil/' . $valueItemregistrationkeluarga->ItemRegistrationID.'#keluarga') " 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 have tried your solutions without tabs:



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


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


I also tried this code:



Try1:



 // Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#'))
$('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');


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


Try 2:
var openTab = $(location.hash).filter(".tab_content");



 if(openTab.length)
$("a[href='"+location.hash+"']").click();



Try 3:



 <script type="text/javascript">
(function activateTabFromHash() if (location.hash) var tabLink = document.querySelector('a[href="' + location.hash + '"]'); if (!tabLink) return false; tabLink.click(); if (location.hash)
setTimeout(function()
window.scrollTo(0, 0);
, 1);
)();
</script>


I am using laravel 5 for this application.



The button can link to the page but it doesn't activate the specified tab.










share|improve this question























  • Try putting the href value in quotation marks in the jQuery selector, e.g. $('.nav-tabs a[href="'+hash+'"]').
    – Delena Malan
    Nov 13 at 13:19










  • sorry, i don't understand. Can you answer and explain a little bit..If it is working, I can accept your answer. Thanks
    – joun
    Nov 14 at 1:38












up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





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=" url('/view_profil/' . $valueItemregistrationkeluarga->ItemRegistrationID.'#keluarga') " 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 have tried your solutions without tabs:



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


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


I also tried this code:



Try1:



 // Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#'))
$('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');


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


Try 2:
var openTab = $(location.hash).filter(".tab_content");



 if(openTab.length)
$("a[href='"+location.hash+"']").click();



Try 3:



 <script type="text/javascript">
(function activateTabFromHash() if (location.hash) var tabLink = document.querySelector('a[href="' + location.hash + '"]'); if (!tabLink) return false; tabLink.click(); if (location.hash)
setTimeout(function()
window.scrollTo(0, 0);
, 1);
)();
</script>


I am using laravel 5 for this application.



The button can link to the page but it doesn't activate the specified tab.










share|improve this question















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=" url('/view_profil/' . $valueItemregistrationkeluarga->ItemRegistrationID.'#keluarga') " 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 have tried your solutions without tabs:



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


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


I also tried this code:



Try1:



 // Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#'))
$('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');


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


Try 2:
var openTab = $(location.hash).filter(".tab_content");



 if(openTab.length)
$("a[href='"+location.hash+"']").click();



Try 3:



 <script type="text/javascript">
(function activateTabFromHash() if (location.hash) var tabLink = document.querySelector('a[href="' + location.hash + '"]'); if (!tabLink) return false; tabLink.click(); if (location.hash)
setTimeout(function()
window.scrollTo(0, 0);
, 1);
)();
</script>


I am using laravel 5 for this application.



The button can link to the page but it doesn't activate the specified tab.







javascript laravel-5 tabs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 at 1:30

























asked Nov 12 at 5:05









joun

52114




52114











  • Try putting the href value in quotation marks in the jQuery selector, e.g. $('.nav-tabs a[href="'+hash+'"]').
    – Delena Malan
    Nov 13 at 13:19










  • sorry, i don't understand. Can you answer and explain a little bit..If it is working, I can accept your answer. Thanks
    – joun
    Nov 14 at 1:38
















  • Try putting the href value in quotation marks in the jQuery selector, e.g. $('.nav-tabs a[href="'+hash+'"]').
    – Delena Malan
    Nov 13 at 13:19










  • sorry, i don't understand. Can you answer and explain a little bit..If it is working, I can accept your answer. Thanks
    – joun
    Nov 14 at 1:38















Try putting the href value in quotation marks in the jQuery selector, e.g. $('.nav-tabs a[href="'+hash+'"]').
– Delena Malan
Nov 13 at 13:19




Try putting the href value in quotation marks in the jQuery selector, e.g. $('.nav-tabs a[href="'+hash+'"]').
– Delena Malan
Nov 13 at 13:19












sorry, i don't understand. Can you answer and explain a little bit..If it is working, I can accept your answer. Thanks
– joun
Nov 14 at 1:38




sorry, i don't understand. Can you answer and explain a little bit..If it is working, I can accept your answer. Thanks
– joun
Nov 14 at 1:38












1 Answer
1






active

oldest

votes

















up vote
0
down vote













JQuery seems to expect the value of href to be in quotes(""), for example href="#keluarga".



Currently, the part where you are selecting the tab ($('.nav-tabs a[href='+hash+']')) would result in '.nav-tabs a[href=#keluarga] if hash='#keluarga'. JQuery throws a syntax exception because the = sign is followed by a # and not a ".



Therefore, ensure that the value of hash is wrapped in quotes. You can change that part of your code to: $('.nav-tabs a[href="'+hash+'"]').






share|improve this answer




















  • i have tried that, the error is gone but it redirect to the page without navigating to the specified tab.
    – joun
    Nov 14 at 3:19










  • Try surrounding the code inside with $( document ).ready(). You can read up about it at learn.jquery.com/using-jquery-core/document-ready
    – Delena Malan
    Nov 14 at 3:26










  • I am sorry but it is still not working.. I am also lost where to find the solution..already tried a lot..don't know why it is not working
    – joun
    Nov 14 at 4:49










  • Post what else you've tried, otherwise there's no way anyone can assist you.
    – Delena Malan
    Nov 14 at 9:10










  • Also, I don't see any nav-tabs class in your html, but you're trying to select it with JQuery. Try $('.nav a[href="'+hash+'"]') instead.
    – Delena Malan
    Nov 14 at 9:13










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256210%2fhow-to-link-to-other-page-tab-in-laravel%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













JQuery seems to expect the value of href to be in quotes(""), for example href="#keluarga".



Currently, the part where you are selecting the tab ($('.nav-tabs a[href='+hash+']')) would result in '.nav-tabs a[href=#keluarga] if hash='#keluarga'. JQuery throws a syntax exception because the = sign is followed by a # and not a ".



Therefore, ensure that the value of hash is wrapped in quotes. You can change that part of your code to: $('.nav-tabs a[href="'+hash+'"]').






share|improve this answer




















  • i have tried that, the error is gone but it redirect to the page without navigating to the specified tab.
    – joun
    Nov 14 at 3:19










  • Try surrounding the code inside with $( document ).ready(). You can read up about it at learn.jquery.com/using-jquery-core/document-ready
    – Delena Malan
    Nov 14 at 3:26










  • I am sorry but it is still not working.. I am also lost where to find the solution..already tried a lot..don't know why it is not working
    – joun
    Nov 14 at 4:49










  • Post what else you've tried, otherwise there's no way anyone can assist you.
    – Delena Malan
    Nov 14 at 9:10










  • Also, I don't see any nav-tabs class in your html, but you're trying to select it with JQuery. Try $('.nav a[href="'+hash+'"]') instead.
    – Delena Malan
    Nov 14 at 9:13














up vote
0
down vote













JQuery seems to expect the value of href to be in quotes(""), for example href="#keluarga".



Currently, the part where you are selecting the tab ($('.nav-tabs a[href='+hash+']')) would result in '.nav-tabs a[href=#keluarga] if hash='#keluarga'. JQuery throws a syntax exception because the = sign is followed by a # and not a ".



Therefore, ensure that the value of hash is wrapped in quotes. You can change that part of your code to: $('.nav-tabs a[href="'+hash+'"]').






share|improve this answer




















  • i have tried that, the error is gone but it redirect to the page without navigating to the specified tab.
    – joun
    Nov 14 at 3:19










  • Try surrounding the code inside with $( document ).ready(). You can read up about it at learn.jquery.com/using-jquery-core/document-ready
    – Delena Malan
    Nov 14 at 3:26










  • I am sorry but it is still not working.. I am also lost where to find the solution..already tried a lot..don't know why it is not working
    – joun
    Nov 14 at 4:49










  • Post what else you've tried, otherwise there's no way anyone can assist you.
    – Delena Malan
    Nov 14 at 9:10










  • Also, I don't see any nav-tabs class in your html, but you're trying to select it with JQuery. Try $('.nav a[href="'+hash+'"]') instead.
    – Delena Malan
    Nov 14 at 9:13












up vote
0
down vote










up vote
0
down vote









JQuery seems to expect the value of href to be in quotes(""), for example href="#keluarga".



Currently, the part where you are selecting the tab ($('.nav-tabs a[href='+hash+']')) would result in '.nav-tabs a[href=#keluarga] if hash='#keluarga'. JQuery throws a syntax exception because the = sign is followed by a # and not a ".



Therefore, ensure that the value of hash is wrapped in quotes. You can change that part of your code to: $('.nav-tabs a[href="'+hash+'"]').






share|improve this answer












JQuery seems to expect the value of href to be in quotes(""), for example href="#keluarga".



Currently, the part where you are selecting the tab ($('.nav-tabs a[href='+hash+']')) would result in '.nav-tabs a[href=#keluarga] if hash='#keluarga'. JQuery throws a syntax exception because the = sign is followed by a # and not a ".



Therefore, ensure that the value of hash is wrapped in quotes. You can change that part of your code to: $('.nav-tabs a[href="'+hash+'"]').







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 at 1:53









Delena Malan

522213




522213











  • i have tried that, the error is gone but it redirect to the page without navigating to the specified tab.
    – joun
    Nov 14 at 3:19










  • Try surrounding the code inside with $( document ).ready(). You can read up about it at learn.jquery.com/using-jquery-core/document-ready
    – Delena Malan
    Nov 14 at 3:26










  • I am sorry but it is still not working.. I am also lost where to find the solution..already tried a lot..don't know why it is not working
    – joun
    Nov 14 at 4:49










  • Post what else you've tried, otherwise there's no way anyone can assist you.
    – Delena Malan
    Nov 14 at 9:10










  • Also, I don't see any nav-tabs class in your html, but you're trying to select it with JQuery. Try $('.nav a[href="'+hash+'"]') instead.
    – Delena Malan
    Nov 14 at 9:13
















  • i have tried that, the error is gone but it redirect to the page without navigating to the specified tab.
    – joun
    Nov 14 at 3:19










  • Try surrounding the code inside with $( document ).ready(). You can read up about it at learn.jquery.com/using-jquery-core/document-ready
    – Delena Malan
    Nov 14 at 3:26










  • I am sorry but it is still not working.. I am also lost where to find the solution..already tried a lot..don't know why it is not working
    – joun
    Nov 14 at 4:49










  • Post what else you've tried, otherwise there's no way anyone can assist you.
    – Delena Malan
    Nov 14 at 9:10










  • Also, I don't see any nav-tabs class in your html, but you're trying to select it with JQuery. Try $('.nav a[href="'+hash+'"]') instead.
    – Delena Malan
    Nov 14 at 9:13















i have tried that, the error is gone but it redirect to the page without navigating to the specified tab.
– joun
Nov 14 at 3:19




i have tried that, the error is gone but it redirect to the page without navigating to the specified tab.
– joun
Nov 14 at 3:19












Try surrounding the code inside with $( document ).ready(). You can read up about it at learn.jquery.com/using-jquery-core/document-ready
– Delena Malan
Nov 14 at 3:26




Try surrounding the code inside with $( document ).ready(). You can read up about it at learn.jquery.com/using-jquery-core/document-ready
– Delena Malan
Nov 14 at 3:26












I am sorry but it is still not working.. I am also lost where to find the solution..already tried a lot..don't know why it is not working
– joun
Nov 14 at 4:49




I am sorry but it is still not working.. I am also lost where to find the solution..already tried a lot..don't know why it is not working
– joun
Nov 14 at 4:49












Post what else you've tried, otherwise there's no way anyone can assist you.
– Delena Malan
Nov 14 at 9:10




Post what else you've tried, otherwise there's no way anyone can assist you.
– Delena Malan
Nov 14 at 9:10












Also, I don't see any nav-tabs class in your html, but you're trying to select it with JQuery. Try $('.nav a[href="'+hash+'"]') instead.
– Delena Malan
Nov 14 at 9:13




Also, I don't see any nav-tabs class in your html, but you're trying to select it with JQuery. Try $('.nav a[href="'+hash+'"]') instead.
– Delena Malan
Nov 14 at 9:13

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256210%2fhow-to-link-to-other-page-tab-in-laravel%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党