Created
January 22, 2013 19:11
-
-
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Needs to be called as
for element in list
do (element) ->
# use element here