I have a situation where I'm using a package/plugin that has a bind function.
I call the bind with a code which is the filter for when myevents fires callbacks. In this senario, three calls will be made to bind, one with parameter 't1', the second for 't2' and the third for 't3'.
When an event is fired from the myevents object, the callback is called (depending on the code) with the data parameter.
My issue is when the callback function is called, I need to know the index number of the loop when it was originally bound. For example, I have the i variable in the alert statement but I dont' know how to get the value there to save for when the callback is eventually fired.
Seems like there would be some combination of "function(data,i)" to accomplish this.
bindList = array('t1','t2','t3');
for (var i = 0; i < bindList.length; i++) {
myevents.bind(bindList[i], function(data) {
alert('data arrive on item ' + i + ': ' + data);
});
}
I would appreciate any help. Thanks.