CLOSED offcanvas onclick on anchor link (for dummies) - where I am wrong?
Hello,
I am using Joomla 3.7, yoo pro latest version. So sorry if my question below is basic for you, but these are my very 1st steps either in javascript world, and I need a starting point with 1 example to be able to learn and play alone with ulkit3. I know from the past the patience of Michael .. so Yooteam might have some minutes to help me here ... I hope, txs.
As example in the page : https://getuikit.com/docs/offcanvas#offcanvas-usage I understand everything in the documentation before ... "JavaScript - Initialization UIkit.offcanvas(element, options);". From this point and after the "Events ...". it is still chinese for me because I miss a practical example to understand how to put that into practice.
CONCRETELY : Using page builder, I have 1 page with different sections (each have an ID).
AND THIS IS WHAT I TRY TO ACHIEVE : I want a small icon always on center-right and when you click on the icon you see the list of IDs of the page (as links). If you click on 1 link, then the offcanvas disappears and the page scrolls at the right IDs
So, I have added an html element into a section to create an offcanvas view with links to anchors into the page. The offcanvas opens correctly, display the links, when I click on 1 link I see page scrolling on the page below the offcanvas BUT IT STOPS AT THIS POINT. The offcanvas remains open (no close onclick) and when I click in the page out of the offcanvas then the offcanvas disappears and the page scroll again on top instead of staying to the anchor (ID of the clicked link) ... not really what I want.
In forum I found that the solution is to use onclick="jQuery.UIkit.offcanvas.offcanvas.hide();" BUT it doesn't work or as I said I am beginner and I did not instantiate javascript properly or ...?
My code into html element inside a section :
<div class="uk-offcanvas-content">
<button class="uk-button uk-button-default uk-position-center-right uk-position-fixed" style="right: 0px;padding-left: 5px; padding-right: 5px; background: rgba(0, 0, 0, 0.73) none repeat scroll 0 0; color:#ffffff;" type="button" uk-toggle="target: #offcanvas-nav"><span uk-icon="icon: chevron-left;"></span></button>
<div id="offcanvas-nav" uk-offcanvas="mode: reveal; overlay: true; flip: true; ">
<div class="uk-offcanvas-bar">
<ul class="uk-nav uk-nav-default">
<li class="uk-active"><a href="#tastingmenu" onclick="jQuery.UIkit.offcanvas.offcanvas.hide();">Tasting Menu</a></li>
<li><a href="#coldstarters" onclick="jQuery.UIkit.offcanvas.offcanvas.hide();">Cold Starters</a></li>
</ul>
</div>
</div>
</div>
Maybe I need to add a script before but this is where I have never done that before and I don't know?
<head>
<script>
WHAT TO PUT HERE ??????????????????????????????????????????
</script>
</head>
<body>
<div class="uk-offcanvas-content">
<button class="uk-button uk-button-default uk-position-center-right uk-position-fixed" style="right: 0px;padding-left: 5px; padding-right: 5px; background: rgba(0, 0, 0, 0.73) none repeat scroll 0 0; color:#ffffff;" type="button" uk-toggle="target: #offcanvas-nav"><span uk-icon="icon: chevron-left;"></span></button>
<div id="offcanvas-nav" uk-offcanvas="mode: reveal; overlay: true; flip: true; ">
<div class="uk-offcanvas-bar">
<ul class="uk-nav uk-nav-default">
<li class="uk-active"><a href="#tastingmenu" onclick="jQuery.UIkit.offcanvas.offcanvas.hide();">Tasting Menu</a></li>
<li><a href="#coldstarters" onclick="jQuery.UIkit.offcanvas.offcanvas.hide();">Cold Starters</a></li>
</ul>
</div>
</div>
</div>
</body>
Thank you
YooRegards
Yannick
Edited