2nd question here and new to coding. I'm trying to change the url when I change the materialize css tabs, using jquery but it isnt working. The html is:
<div class="row">
<div class="col s12">
<ul class="tabs tabs-transparent">
<li class="tab col s6 m6 l6 blue z-depth-0"><a class="waves-effect waves-blue-darken-2" href="#favorites">FAVORITES</a></li>
<li class="tab col s6 m6 l6 card-panel blue z-depth-0"><a class="active waves-effect waves-blue-darken-3" href="#recommended">RECOMMENDED</a></li>
</ul>
</div>
</div>
</header>
<div class="containter">
<section class="col s12 card-panel white content z-depth-0" id= "favorites">
<ul class="collection fixed"> (A LOT OF LI ELEMENTS)
<section class="col s12 card-panel white content z-depth-0" id="recommended">
<!--STARTS LIST-->
<ul class="collection">(AGAIN A LOT OF LI ELEMENTS)
And the Jquery:
$(function() {
var $content = $('.content');
$(document).on('click', '.tabs', function() {
var href = $(this).attr('href')
window.history.pushState({$content}, '', href)
$content.load(href)
return false;
});
});
On console it says:
Uncaught DOMException: Failed to execute 'pushState' on 'History': HTMLElement object could not be cloned.
at HTMLUListElement.<anonymous> (file:///C:/Users/Carla/Desktop/streema-estatica/js/functions.js:13:22)
at HTMLDocument.dispatch (file:///C:/Users/Carla/Desktop/streema-estatica/js/jquery-3.2.1.min.js:3:10316)
at HTMLDocument.q.handle (file:///C:/Users/Carla/Desktop/streema-estatica/js/jquery-3.2.1.min.js:3:8343)
If I take out the $content var in the pushState, the console says:
jquery-3.2.1.min.js:4 Uncaught TypeError: Cannot read property 'indexOf' of undefined
at r.fn.init.r.fn.load (jquery-3.2.1.min.js:4)
at HTMLUListElement.<anonymous> (functions.js:14)
at HTMLDocument.dispatch (jquery-3.2.1.min.js:3)
at HTMLDocument.q.handle (jquery-3.2.1.min.js:3)
Thank you!