insertBefore
Inserts an item into a Menu before the specified referenceItem.
Example
<ul id="menu">
<li>Item 1
<ul>
<li>Sub Item 1</li>
<li>Sub Item 2</li>
<li>Sub Item 3</li>
</ul>
</li>
<li>Item 2
<ul>
<li>Sub Item 1</li>
<li>Sub Item 2</li>
<li>Sub Item 3</li>
</ul>
</li>
</ul>
<script>
$("#menu").kendoMenu();
// get a reference to the menu widget
var menu = $("#menu").data("kendoMenu");
//
menu.insertBefore(
[{
text: "Item 1",
url: "https://www.telerik.com" // Link URL if navigation is needed, optional.
},
{
text: "<b>Item 2</b>",
encoded: false, // Allows use of HTML for item text
content: "text" // content within an item
},
{
text: "Item 3",
imageUrl: "https://demos.telerik.com/kendo-ui/content/shared/icons/sports/swimming.png", // Item image URL, optional.
items: [{ // Sub item collection
text: "Sub Item 1"
},
{
text: "Sub Item 2"
}]
},
{
text: "Item 4",
spriteCssClass: "imageClass3" // Item image sprite CSS class, optional.
}],
"li:first-child"
);
</script>
Parameters
item Object|Array
Target item, specified as a JSON object. Can also handle an array of such objects.
referenceItem String|Element|jQuery
A reference item to insert the new item before
Returns
kendo.ui.Menu
Returns the Menu object to support chaining.