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.

Dynamically inject Menu markup

Home Forums Older releases 0.9.x Dynamically inject Menu markup

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1327
    muscatian
    Participant

    Is it possible to generate the menu dynamically through jquery ajax?

    I cannot load the menu at the time of page load. I will get the menu structure later through jquery ajax. After the markup data is retrieved through ajax I populated the menu. At that time, how can I ask your menu script to build my menu? Thanks.

    #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
    	});
    
    });
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘0.9.x’ is closed to new topics and replies.