The following is a part of my bb view:
define(['backbone', 'tools/logger', 'icanhaz', 'view/loader', 'text!template/root.ich',
'view/users', 'view/chart/monthly_balance', 'datatables'],
function(Backbone, logger, ich, loader, template,
UsersView, MonthlyBalanceChartView) {
// here I can see both `loader` and `template` variables
'use strict';
return Backbone.View.extend({
[...]
initialize: function(options) {
logger.init('root');
// I can't see `loader` and `template` here
},
[...]
});
});
The problem is, that I can't see two variables inside the view's initialize method and I've got no idea why. I thought it should be caught into a closure. I make a test using google chrome's developer tools breakpoint. just before the use strict
, I can see everything (the loader and template variables are set). All other variables are accessible.
For example, the entire loader file is:
define(
['icanhaz', 'tools/logger'],
function(ich, logger) {
return {
loadTemplate: function(tpl) {
$(tpl).each(function() {
if (this.outerHTML) {
ich.addTemplate(this.id, $(this).text());
logger.log('LOADED', this.id);
}
});
}
};
});
What is the reason for those vars to be undefined?