Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
ons-sliding-menu: active item
-
What a simple way is to determine “active item” in the ons-sliding-menu?
I need this to add a class and add “prevent repeating clicks” if current page is open(it’s breaks my script). I have been checking code, forum, doc alreadyhm… maybe simple is add “toggle class”
-
@Евгений-Гедройц The simplest way would be to dynamically add/change the CSS class and mark the link as active. You would also be able to disable the onclick event thus preventing double fires. So your two classes, active and notactive, are css that enables the link and disables it as well.
var activeLink = ''; function setActive(newLink) { document.getElementById(activeLink).className='notactive'; document.getElementById(newLink).className='active'; activeLink=newLink; }
-
@munsterlander thank you for reply, but sliding menu not change location.href
It’s Single Page Application without history api. “Preventing double fires” is not enough for this i suppose, if i’ll need to click from other pages, but i’ll try disable the onclick
-
@Евгений-Гедройц Updated the code to reflect the easiest possible way to pull this off that I can think of.