Customize location of goToHome button

108 views
Skip to first unread message

Alan McConchie

unread,
Sep 9, 2018, 3:16:34 PM9/9/18
to codelab...@googlegroups.com
For every codelab I've seen anywhere on the web, the green "Done" button at the end always seems to send the browser back to the root directory of the website. Is there any way to customize this behavior, so the Done button takes you somewhere else?

For example, I want to deploy several codelabs tutorials to a subfolder of my website (or on github pages), and instead of having users go back to the root of my website after finishing each tutorial, I want to send them to the enclosing folder that contains all the other tutorials.

For example, I have a tutorial here:


And when the user finishes it, I want them to end up here:


But instead, they always end up here, which is not what I want:


I don't see anywhere either in the claat command-line options or in the codelabs metadata where I can customize this. Is it possible?

Looking at the codelabs source code I see that the "Done" button runs the _goToHome function, and this function seems look for an "index" parameter in the URL, but I'm not sure how this parameter would get populated by the tutorial itself. 



Thanks,
Alan
Message has been deleted

abam...@plexscape.com

unread,
Oct 4, 2018, 6:52:04 AM10/4/18
to codelab-authors
Hi Alan,

As a workaround you could override the _goToHome function in a custom Javascript file and include it in your HTML codelab files:

document.addEventListener("DOMContentLoaded", function() {
 const lab = document.querySelector('google-codelab');
 lab._goToHome = function() {
 //Put your logic here
 }
});

but be advised that this is more of a hack since _goToHome seems to be a private method. It would be great though to be able to pass the location via claat options.
Reply all
Reply to author
Forward
0 new messages