Extras - Context Menu
Plugin initialization Context menu initialization options
Add data-toggle="context"
to any element that needs a custom context menu. And point data-target
attribute to your custom context menu.
<div data-toggle="context" data-target=".context-menu"></div>
<div class="context-menu">
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li class="divider"></li>
<li><a href="#">Something else here</a></li>
</ul>
</div>
Also content menu can be initialized via JavaScript call. In this case data attributes are not required, target can be set in plugin configuration.
$('.context').contextmenu({
target:'#context-menu',
before: function(e,context) {
// execute code before context menu if shown
},
onItem: function(context,e) {
// execute on menu item selection
},
scopes: 'tbody > tr'
})
Content attachment Panel and content elements attachment
Also context menu can be attached to the link or any other content elements like headings, paragraphs, span's, lists, labels, form components, buttons, button groups etc.
Example with context menu attached to the whole table.
# | Description | Date | Actions |
---|---|---|---|
1 | Cozy sphinx waves quart jug of bad milk. | July 13, 2014 | |
2 | Few quips galvanized the mock jury box. | July 14, 2014 | |
3 | Bawds jog, flick quartz, vex nymphs. Waltz, bad nymph. | July 15, 2014 |
Example with context menu attached to the table row. Attached to the first row.
# | Description | Date | Actions |
---|---|---|---|
1 | Cozy sphinx waves quart jug of bad milk. | July 13, 2014 | |
2 | Few quips galvanized the mock jury box. | July 14, 2014 | |
3 | Bawds jog, flick quartz, vex nymphs. Waltz, bad nymph. | July 15, 2014 |
Example with context menu attached to the table cell only. Attached to cells with links.
# | Description | Date | Actions |
---|---|---|---|
1 | Cozy sphinx waves quart jug of bad milk. | July 13, 2014 | |
2 | Few quips galvanized the mock jury box. | July 14, 2014 | |
3 | Bawds jog, flick quartz, vex nymphs. Waltz, bad nymph. | July 15, 2014 |
Example with context menu attached to the table content. Attached to action icons.
# | Description | Date | Actions |
---|---|---|---|
1 | Cozy sphinx waves quart jug of bad milk. | July 13, 2014 | |
2 | Few quips galvanized the mock jury box. | July 14, 2014 | |
3 | Bawds jog, flick quartz, vex nymphs. Waltz, bad nymph. | July 15, 2014 |
Context menu options Dropdown menu options and colors
Plugin events Context dropdown menu events
Current example demonstrates context menu with show.bs.context
event. This event fires immediately when the context dropdown menu is opened.
$('#myMenu').on('show.bs.context',function () {
// do something...
});
Current example demonstrates context menu with hide.bs.context
event. This event is fired immediately when the hide instance method has been called.
$('#myMenu').on('hide.bs.context',function () {
// do something...
});