I have a view class extending SugarCRM CreateView
and I want this
to be this.model
in function checkMonths
when the field starting_months_c
is changed, so I could type this.get()
instead of this.model.get()
.
/**
* @class View.Views.Base.DoVPCreateView
* @alias SUGAR.App.view.views.DoVPCreateView
* @extends View.Views.Base.CreateView
*/
({
extendsFrom: 'CreateView',
initialize: function(options) {
this._super('initialize', arguments);
// ....
this.model.on('change:starting_month_c', _.bind(this.checkMonths, this.model));
// ....
},
checkMonths: function() {
if (this.get('starting_month') == 12) {
// ....
}
}
Unfortunately, this construct does not work. I wonder, maybe it is because the .on()
function somehow sets the context itself?
I found out in the doc, that you can pass the context to the function as third parameter
object.on(event, callback, [context])
I tried this but the result is still the same - the view is this
, not the model
.