Based on the click of the list elements ( whose ids I set to be the same as the objects), I want to call a function ( in this case, just print that object). I don't want to attach an onclick to every list item. I want something like this.
$('#li.menu').click(function(){
$('li').each(function(){
var id= $(this).attr('id');
}
//when the id is clicked, see the object and if it's there and call print on it)
});
//sample function:
function print(x){
console.log(x);
}
Var myObject = {
obj1:{ JSON here},
obj2:{ JSON here }
}
<!-- Bootstrap Simple Sidebar: Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav" id="menu">
<li>
<a id="obj1" href="#repo">Repository </a>
</li>
<li>
<a id="obj2" href="#config">Configuration</a>
</li>
</ul>
</div>