Skip to content

Instantly share code, notes, and snippets.

@arunk
Created January 22, 2013 19:11
Show Gist options
  • Select an option

  • Save arunk/4597421 to your computer and use it in GitHub Desktop.

Select an option

Save arunk/4597421 to your computer and use it in GitHub Desktop.
how do i refer to the callback of each element in the list rather than the callback of the last element?
list = [
{
data: 1
callback: function(res)...
},{
data: 2
callback: function(res)...
}
]
for element in list
callAFunction element.data, (response) ->
myData = lookUpStuff(response)
element.callback(myData) #only calls the last element in the list instead of the callback for each element
@arunk
Copy link
Copy Markdown
Author

arunk commented Jan 25, 2013

Needs to be called as

for element in list
do (element) ->
# use element here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment