President/CEO
$(document).ready(function(){ // Create an instance of orgBuilder within the target element(s). // If $elem represents multiple elements, orgBuilder will be instantiated within each one. // Use the nodeHeight option to set custom node height. var $elem = $( '#orgchart' ); $elem.orgBuilder(); // Define an alert function. var simpleAlert = function() { alert( 'Hello from the ' + nodeClicked.attr( 'name' ) + ' department!' ); }; // Use the addOption method to add a new button to the option menu with the provided text. // The function provided is called when the button is clicked. $elem.orgBuilder( 'addOption', 'Simple Alert', simpleAlert ); // Let's make it interesting. // Define a recursive function to 'walk up' the node tree and add class 'highlight' to each ancestor node. var showPath = function() { function walk( step ){ var parent = $elem.orgBuilder( 'findParentNode', step ); step.addClass( 'highlight' ); if ( step.parent( '.family' ).attr( 'id' ) !== 'root' ){ walk( parent ); } } $( '.highlight' ).removeClass( 'highlight' ); walk( nodeClicked ) }; // Use the addOption method to add a new button to the option menu with the provided text. // The function provided is called when the button is clicked. $elem.orgBuilder( 'addOption', 'Show Chain of Command', showPath ); });