0

Supose I've:

var items = {
  '1': {
    id: 1
  },
  '2': {
    id: 2
  },
}

for (var item in itemns) {
  var item = items[item];

  $(object).on('signal', function () {
    doSomethingElse(item.id);
  });
}

Always doSomethingElse is called with id = 2, I know why it happens, but how can I avoid this in other words how can i workaround this ?

Victor Aurélio
  • 2,355
  • 2
  • 24
  • 48
  • The question is what you want to achieve. You are binding two events (one with id=1 and an identical one with id=2). It is hard to see what the possible purpose could be. (Also, "var item = items[item];" is really, really ugly) – Olaf Jul 06 '16 at 14:34
  • `object` would be two different objects, that when clicked delete the object with id 1, and 2 respectively. – Victor Aurélio Jul 06 '16 at 14:43

0 Answers0