Skip to content

Instantly share code, notes, and snippets.

@freshtonic
Created January 22, 2012 08:01
Show Gist options
  • Save freshtonic/1656210 to your computer and use it in GitHub Desktop.
Save freshtonic/1656210 to your computer and use it in GitHub Desktop.
Weird JS problem
(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);
@freshtonic
Copy link
Author

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