When I use a variable in javascript, it gives an error
ReferenceError: getalletje is not defined
, depending on where I declare it.
This is where I declare the variable:
get_name: function(){
var getalletje = 5;
return getalletje;
},
Where I'm trying to use the variable:
self.$('.geldinuit-button').click(function(){
self.screen_selector.show_popup('geldinuit',{
message: _t('Popup titel'),
comment: _t('getalletje'),
confirm: function(){
window.alert(getalletje);
},
});
});
It gives an error like this.
But: If I put var getalletje = 5;
just above self.$('.geldinuit-button').click(function(){
, it works.
Something extra I need to do?
Edit for Shomz: This is the full code:
.............
self.set_smart_status(status.newValue);
});
this.$el.click(function(){
self.pos.connect_to_proxy();
});
},
});
module.PosWidget = module.PosBaseWidget.extend({
template: 'PosWidget',
init: function() {
this._super(arguments[0],{});
this.pos = new module.PosModel(this.session,{pos_widget:this});
this.pos_widget = this; //So that pos_widget's childs have pos_widget set automatically
.............................
............................
get_name: function(){
var getalletje = 5;
return getalletje;
},
...........................
...........................
self.$('.geldinuit-button').click(function(){
self.screen_selector.show_popup('geldinuit',{
message: _t('Popup titel'),
comment: _t('getalletje'),
confirm: function(){
window.alert( this.get_name() );
},
});
});
..........................