I got this
for(m in _data.data)
{
var _person= new Person(_data.data[m].Properties); //return a person object
$('ul.v_list').append("<li>"+_person.person_name+'</li>').css("cursor", "pointer");
$('ul.v_list').find('li:last').bind('click', function(){onPersonChanged(_person)});
}
And this another function
function onPersonChanged(person){
alert("You have clicked " + person.person_name);
};
Everytime is passing the last object created in the Person Object to the onPersonChanged function so it alerts the last name in the list if I click in the first li or another li element nested in the ul. eg.:
<ul class='v_list'>
<li>James</li>
<li>Paul</li>
<li>Bonnie</l>
</ul>
When I do a click in Paul I expect an alert showing "You have clicked Paul" instead I always get the last one li in the list: "You have clicked Bonnie". How can I get the correct alert for the selected li?