I have a side bar that is displayed in all views. In that side bar I have a dropdown menu to select some tours that are made with intro.js. There is a quick start, that works perfect. I want to add some options with the names of the views in the tutorial dropdown so that when I click on it I go to the view and start the tutorial. Important, there is an option to start a tutorial when you enter that view, but I don't want that, because if I access redirected from another part it will always start the tutorial, I want it to start only from the tutorial dropdown menu. The problem I have is that my js function switches me to another view but the tutorial starts and stops from one (it shows a fraction of a second).
This is what i have. The dropdown menu:
<div class="language-selector">
<!-- Dropdown Trigger -->
<a id="tutorial" class="dropdown-trigger sidebar-links a" href="#" data-target="tutorialDropdown">
<span style="display: flex; align-items: center;">
<i class="fas fa-question-circle"></i>
{% trans "Tutorial" %}
<i class="fas fa-caret-down"></i>
</span>
</a>
<!-- Dropdown Structure -->
<ul id="tutorialDropdown" class="dropdown-content">
<li>
<button class="start-tour-button" onclick="startTourAndRedirect('quick-start', '')">
Quick Start
</button>
</li>
<li>
<button class="start-tour-button" onclick="startTourAndRedirect('review-panel', '{% url 'validate' %}')">
Review Panel
</button>
</li>
</ul>
</div>
My js code:
function startTourAndRedirect(tourName, url) {
if (url !== "") {
window.location.href = url;
}
let steps = [];
if (tourName == "quick-start") {
steps = [
/* steps for quic-start */
];
} else if (tourName == "review-panel") {
steps = [
/* steps for review-panel */
];
}
console.log(steps);
if (steps.length > 0) {
introJs()
.setOptions({
steps: steps,
showProgress: true,
showBullets: false,
disableInteraction: true,
})
.start();
}
else {
console.log("No steps found");
}
}
I solved this, saving in a cookie the selected tour name, and starting the tutorial when the view changes.
and the js code: