LIDOR SYSTEMS

Advanced User Interface Controls and Components

IntegralUI Web

Documentation and API Reference


itemadding(e)

Occurs before a new item is added to the tree collection.

Event Data

ParamTypeDetails
eObjectAn event object which contains the item

Remarks

This event can be handled by binding the 'itemadding' event to the Menu widget object.

Version Information

Supported in: v1.0.

Example

In this example we are showing how to handle itemadding event in Menu widget.

By handling this event you can prevent adding of item depending on some custom conditions. By returning a false value, you can cancel this event. Whenever the 'Add Item' button is clicked a new item is added, until Menu contains 10 items. Afterwards, additional items can't be added.

$(document).ready(function() {

// Create an instance of Menu widget

var $bar = $('#menu').menu();

 

// Get the number of present items in Menu

var getItemCount = function(){

return $bar.menu("getList").length + 1;

}

 

// Create a new item with its header title

var createNewItem = function(){

return { text: "Item" + getItemCount() };

}

 

// When 'Add Item' button is clicked, add a new item to the Menu

var add = function(){

var item = $bar.menu("addItem", createNewItem());

}

 

// Create a handler to the itemadding event and allow Menu to contain only 3 items

$tree.on({

"itemadding": function(e){

var itemCount = getItemCount() - 1;

if (itemCount > 10)

return false;

});

});

<!DOCTYPE html>

<html>

<head>

<link rel="stylesheet" href="css/integralui.menu.css" />

<link rel="stylesheet" href="css/themes/theme-blue.css" />

<script type="text/javascript" src="external/jquery-1.9.1.min.js"></script>

<script type="text/javascript" src="external/jquery.ui.core.min.js"></script>

<script type="text/javascript" src="external/jquery.ui.widget.min.js"></script>

<script type="text/javascript" src="js/jquery.integralui.widget.min.js"></script>

<script type="text/javascript" src="js/jquery.integralui.menu.min.js"></script>

</head>

<body>

<button type="button" onclick="add()" />Add Item</button>

<div id="menu" class="widget"></div>

</body>

</html>

.widget

{

width: 600px;

height: 0;

}

Samples

See Also