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.

Re: Dynamically inject Menu markup

Home Forums Older releases 0.9.x Dynamically inject Menu markup Re: Dynamically inject Menu markup

#1596
admin
Keymaster

You just need to call the SmartMenus initialization code after you have inserted the menu structure in the DOM. Here is a very basic example that gets the menu structure from an external file, prepends it in the body and then the menu is initialized:

$.get('URL_to_menu_structure_file', function(htmlStr) {

	// insert menu structure
	$('body').prepend(htmlStr);

	// SmartMenus initialization code
	$('#main-menu').smartmenus({
		subMenusSubOffsetX: 1,
		subMenusSubOffsetY: -8
	});

});