Created
January 22, 2012 08:01
-
-
Save freshtonic/1656210 to your computer and use it in GitHub Desktop.
Weird JS problem
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
(function() { | |
var fixedAssetColumns, totalsRowTemplate; | |
fixedAssetColumns = [ | |
{ | |
name: 'description' | |
}, { | |
name: 'date' | |
} | |
]; | |
console.log(fixedAssetColumns); // Prints fixedAssetColumns to console (as one would expect) | |
totalsRowTemplate = function() { | |
return tr(function() { | |
// Uncaught ReferenceError: fixedAssetColumns is not defined | |
// Weird because this is ultimately nested within the same function scope and should be captured. | |
return _.each(fixedAssetColumns, function(col) { | |
return td; | |
}); | |
}); | |
}; | |
}).call(this); |
You haven't defined 'td' anywhere, not sure if that's the problem you are hitting but it would definitely cause a problem somewhere.
Forget the td, I trimmed things down to make a smaller example and left in some stuff by accident. I'll edit it out.
Was nothing to do with my JS. It was CoffeeKup converting a function back to a string, and reevaluating in different context thus losing the closed-over variables. Thanks for taking the time to look though :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why does is an Uncaught ReferenceError thrown when fixedAssetColumns is referenced in the totalsRowTemplate function? It should be bound to the variable defined in the surrounding function scope.