Added list_attribute addition
This commit is contained in:
parent
7e9d445051
commit
2a6aa0b04f
@ -25,6 +25,39 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
// Select all the tab links
|
||||||
|
const tabLinks = document.querySelectorAll('.nav-link');
|
||||||
|
|
||||||
|
tabLinks.forEach(function(link) {
|
||||||
|
// Add a click event listener to each tab link
|
||||||
|
link.addEventListener('click', function(e) {
|
||||||
|
// Prevent the default action
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Get the tab ID
|
||||||
|
const tabId = this.getAttribute('href').match(/simple-tabpanel-(\d+)/)[1];
|
||||||
|
|
||||||
|
// Update the URL with the new query parameter
|
||||||
|
const newUrl = updateQueryStringParameter(window.location.href, 'list', tabId);
|
||||||
|
window.history.pushState({path:newUrl}, '', newUrl);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update the URL with the new query parameter
|
||||||
|
function updateQueryStringParameter(uri, key, value) {
|
||||||
|
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
|
||||||
|
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
|
||||||
|
if (uri.match(re)) {
|
||||||
|
return uri.replace(re, '$1' + key + "=" + value + '$2');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return uri + separator + key + "=" + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="tab-content pt-5" id="tab-content">
|
<div class="tab-content pt-5" id="tab-content">
|
||||||
{% for habit_list in habit_lists %}
|
{% for habit_list in habit_lists %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user