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
	});

});

Register

You will be emailed a link to set your password.

Login

Lost password?