LIDOR SYSTEMS

Advanced User Interface Controls and Components

IntegralUI Web

Documentation and API Reference


itemRemoving(e)

Occurs before an item is removed from the tree collection.

Event Data

ParamTypeDetails
eObjectAn event object which contains the item

Remarks

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

Version Information

Supported in: v1.0.

Example

An example explaining how to create a handle to the itemremoving event in Menu widget.

By handling this event you can prevent removing of items depending on some custom conditions. By returning a false value, you can cancel this event. Whenever the 'Remove Item' button is clicked the currently selected item will be removed from the Menu, until only one root item remains.

$(document).ready(function() {

// Create an instance of Menu widget

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

 

// Get the item that is currently selected in Menu

var getCurrentSelection = function(){

return $bar.menu("option", "selectedItem");

}

 

// When 'Remove Item' button is clicked, it removes the currently selected item from the Menu

var remove = function(){

$bar.menu("removeItem", getCurrentSelection());

}

 

// Create a handler to the itemremoving event

$tree.on({

"itemremoving": function(e){

var itemCount = $bar.menu("getList").length;

if (itemCount <= 1)

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="remove()" />Clear</button>

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

<ul>

<li><span>MenuItem1</span></li>

<li><span>MenuItem2</span>

<ul>

<li><span>MenuItem21</span></li>

<li>><span>MenuItem22</span></li>

<li ><span>MenuItem23</span></li>

<ul>

<li><span>MenuItem231</span></li>

<li ><span>MenuItem232</span>

<ul>

<li><span>MenuItem2321</span></li>

<li><span>MenuItem2322</span></li>

</ul>

</li>

<li><span>MenuItem233</span></li>

</ul>

</li>

<li><span>MenuItem24</span></li>

</ul>

</li>

<li ><span>MenuItem3</span></li>

<ul>

<li><span>MenuItem31</span></li>

<li><span>MenuItem32</span></li>

<li><span>MenuItem33</span></li>

</ul>

</li>

</ul>

</div>

</body>

</html>

.widget

{

width: 600px;

height: 0;

}

Samples

See Also