-1

I have a problem with event in meteor app. I have a place in code for "active" person. When that person stopa being active a new person appears I need to get the ID of that person on click

'click .person .fa-close': function(event, template) {
    event.preventDefault();
    var getid = $(event.target);
    console.log(getid.data('id'));
}

On the first click I will get correct data id, but when the new person with a new id shows up, in console.log I will get the old ID.

When I log event.target I have a good target with good id. But when I want to get ID, I end up with the old one. Anyone?

Michel Floyd
  • 18,793
  • 4
  • 24
  • 39
Abdiel
  • 41
  • 6
  • so when you console log event.target its the new dom element, but when you do event.target.id its the old id, and not the one from the new element? can you show the template – PhilVarg Oct 30 '15 at 21:46
  • Is your event attached to a *person* level template? If so `this` will automatically be the data context of that template. This avoids the need to get the event target and is unambiguous. – Michel Floyd Oct 30 '15 at 22:01
  • Hi. Thx for answer. Here is my Jade code: http://jsfiddle.net/LLjmejry/ Event is attached to this template. – Abdiel Oct 31 '15 at 17:38

1 Answers1

0
$(event.target).attr('data-id')

I changed .data to .attr and it works

Tim
  • 41,901
  • 18
  • 127
  • 145
Abdiel
  • 41
  • 6