The code below shows how to create a menu programmatically and attach it to the searchbox component.
// retrieve data from server
var menus = [
{name:'all',text:'All News'},
{name:'sports',text:'Sports News'}
];
// create the menu
var mm = $('<div></div>').appendTo('body');
mm.menu();
for(var i=0; i<menus.length; i++){
mm.menu('appendItem', menus[i]);
}
// attach the menu to the searchbox
$('#sb').searchbox({menu:mm})