Advanced User Interface Controls and Components
Gets the parent item of the specified item.
Param | Type | Details |
---|---|---|
item | Object | The item for which parent item is requested |
An item object that represents the parent of the specified item.
Supported in: v1.0.
In this example we are showing how to call getItemParent method. If item is present in tree hierarchy, an alert box will popup with message stating the parent.
$(document).ready(function() {
// Create an instance of Menu widget
var $bar = $('#menu').menu();
var showParent = function(){
var item = $bar.menu("findItemById", '231');
if (item){
var parent = $bar.menu("getItemParent", item);
if (parent)
alert("The parent for item " + item.text + " is: " + parent.text);
else
alert("The item " + item.text + " has no parent, it's a root item");
}
}
});
<!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>
<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;
}