items.data Function
Adds a custom data callback to be added to the context of menu item - useful to attach context dynamically.
Example
<button id="dropDownButton">Command</button>
<script>
var commands = {
"command_one": function () {
alert("Command One Executed!")
},
"command_two": function () {
alert("Command Two Executed!")
},
"default_command": function () {
alert("Default Executed!")
}
}
function getContext(item) {
return {
command: commands[item.id]
}
}
var dropDownButton = $("#dropDownButton").kendoDropDownButton({
items: [
{ id: "command_one", text: "Command 1", data: getContext},
{ id: "command_two", text: "Command 2", data: getContext}
],
click: function(ev) {
if (ev.target.data("command")) {
ev.target.data("command")();
} else {
commands["default_command"]();
}
}
}).data("kendoDropDownButton");
</script>