<button id="menuDefault" class="hx-btn">Default</button>
<button id="menuDisabled" class="hx-btn">Disabled menu items</button>
<button id="menuNoSelect" class="hx-btn">Unselectable menu items</button>
<button id="menuMixed" class="hx-btn">Mixed Items</button>
defaultMenu = new hx.Menu('#menuDefault')
defaultMenu.items(["item 1","item 2","item 3"])
disabledMenu = new hx.Menu('#menuDisabled')
disabledMenu.items([
{
text: 'Disabled Item 1',
disabled: true
},{
text: 'Disabled Item 2',
disabled: true
},{
text: 'Disabled Item 3',
disabled: true
}
])
unselectableMenu = new hx.Menu('#menuNoSelect')
unselectableMenu.items([
{
text: 'Unselectable Item 1',
unselectable: true
},{
text: 'Unselectable Item 2',
unselectable: true
},{
text: 'Unselectable Item 3',
unselectable: true
}
])
mixedMenu = new hx.Menu('#menuMixed')
mixedMenu.items([
{
text: 'Disabled Item 1',
disabled: true
},{
text: 'Item 1'
},{
text: 'Disabled Item 2',
disabled: true
},{
text: 'Unselectable Item 1',
unselectable: true
},{
text: 'Item 2'
},{
text: 'Unselectable Item 2',
unselectable: true
}
])
<button class="hx-btn hx-action menuButtonNamed">hx-action</button>
<button class="hx-btn hx-positive menuButtonNamed">hx-positive</button>
<button class="hx-btn hx-negative menuButtonNamed">hx-negative</button>
<button class="hx-btn hx-warning menuButtonNamed">hx-warning</button>
<button class="hx-btn hx-info menuButtonNamed">hx-info</button>
<button class="hx-btn hx-contrast menuButtonNamed">hx-contrast</button>
<button class="hx-btn hx-compliment menuButtonNamed">hx-compliment</button>
menuItems = ["item 1","item 2","item 3"]
menuExample = hx.selectAll('.menuButtonNamed').forEach(function(node){
menu = new hx.Menu(node.node());
menu.items(menuItems);
});
<button class="hx-btn" id="collapsibleMenu">Menu with children</button>
<button class="hx-btn" id="collapsibleMenu-feature-flag">Menu with children (feature flag)</button>
menu = new hx.Menu('#collapsibleMenu', {
items:[
{
text: 'Item 1',
children: [
'Sub item 1',
'Sub item 2',
]
},
{
text: 'Item 2',
children: [
'Sub item 1',
'Sub item 2',
]
}
]
});
menu = new hx.Menu('#collapsibleMenu-feature-flag', {
featureFlags: {
useUpdatedStructure: true,
},
items:[
{
text: 'Item 1',
children: [
'Sub item 1',
'Sub item 2',
]
},
{
text: 'Item 2',
children: [
'Sub item 1',
'Sub item 2',
]
}
]
});
hx.Dropdown
and a list of menu items. menu = new hx.Menu('#selector');
menu.renderer(function(elem, item){
// do your render stuff
});
menu.render(data);