Skip to content

Instantly share code, notes, and snippets.

@cpaul007
Last active December 14, 2021 09:32
Show Gist options
  • Save cpaul007/96dacde33ffd21126b3358f52a42a93c to your computer and use it in GitHub Desktop.
Save cpaul007/96dacde33ffd21126b3358f52a42a93c to your computer and use it in GitHub Desktop.
Closing the off-canvas panel after clicking on the menu item
(function($){
$(document).ready(function(){
let ocps = document.querySelectorAll('.oxy-ou-off-canvas');
ocps.forEach((oc) => {
let menuitems = oc.querySelectorAll('.menu-item');
menuitems.forEach( (menuItem) => {
let anchor = $(menuItem).children('a');
anchor.on('click', function(e){
let aHref = $(this).attr('href');
if( typeof aHref != 'undefined' && aHref != '#' ) {
let triggerSelector = oc.getAttribute('data-trigger-selector');
$(triggerSelector).trigger('click');
}
});
});
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment