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)
  • You must be logged in to reply to this topic.

Register

You will be emailed a link to set your password.

Login

Lost password?