Skip to content

Instantly share code, notes, and snippets.

@ryanKinoti
Last active June 22, 2023 19:41
Show Gist options
  • Save ryanKinoti/9a54be6a64f941fbc5ad46e8bef728cb to your computer and use it in GitHub Desktop.
Save ryanKinoti/9a54be6a64f941fbc5ad46e8bef728cb to your computer and use it in GitHub Desktop.
Tab switching action
<script>
// tab switching
function switchcommon(evt, mainName) {
var i, tabcontent, tablinks;
//get all elements under tabcontent and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(mainName).style.display = "block";
evt.currentTarget.className += " active";
}
document.getElementById("defaultOpen").click();
</script>
<li class="active">
<a class="tablinks" id="defaultOpen" onclick="switchcommon(event, 'dashboard')"
style="cursor: pointer" title="Dashboard">
<i class="uil uil-estate"></i>
<span class="text">Dashboard</span>
</a>
</li>
@ryanKinoti
Copy link
Author

ryanKinoti commented Jun 22, 2023

consider the list item on navigation.blade.php.
when I click on the tag of the class "tablinks" the switch the onclick method calls the script in the dashboard.blade.php
the dashboard file calls the navigation file through the @include directive.

what i want is to include AJAX method in the script which will also fetch data from a particular route that access a particular method in a controller and update the content using normal blade syntax and not json please😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment