Start a new discussion

To start a new discussion please visit the discussions section of the GitHub home page of the project.

Discussions on GitHub

You can also search our old self-hosted forums for any useful information below but please note that posting new content here is not possible any more.

Reply To: Dynamically changing bottomToTopSubMenus value

Home Forums Older releases 1.0.x Dynamically changing bottomToTopSubMenus value Reply To: Dynamically changing bottomToTopSubMenus value


I found a post on the 0.9.x forums that got me most of the way there and dug through the code to get the rest. Here’s what I ended up doing:

// Switch the mode of the submenu dropdowns, or instantiate the menu
// for the first time if it hasn't happened yet.
function navMode(dropMode) {

	if (typeof dropMode === 'undefined' || dropMode !== 'dropUp') {
		dropMode = 'dropDown';

	// If the nav has not yet been set up, set it up with the default options.
	if (typeof jQuery('.main-menu__items').data('smartmenus') === 'undefined') {

	// If the mode is different than the one we passed in, change the option on the fly.
	// The subOrientation variable is global and contains the current state so we don't do the actions any more often than necessary.
	if (subOrientation != dropMode) {
		subOrientation = dropMode;
		if (dropMode == 'dropUp') {
			jQuery('.main-menu__items').data('smartmenus').opts.bottomToTopSubMenus = true;
		} else {
			jQuery('.main-menu__items').data('smartmenus').opts.bottomToTopSubMenus = false;

The setupNav() function holds the main initialization function along with as the setup of the menu animations. Now I can use this navMode() function as often as needed since it’s very low-overhead and only does something when it needs to.