Kearobi
03/08/2021, 3:50 PMSteve Goldberg
03/08/2021, 4:27 PMKearobi
03/08/2021, 4:46 PMlet model = new CustomModel();
model.fetch({
email: '<mailto:testing@gmail.com|testing@gmail.com>'
}).done(function (result) {
HeaderView.prototype.childViews['Header.SavedCart.Dropdown.View'] = function () {
return new HeaderSavedCartDropdown({
application: container,
model: result
});
}
});
Kearobi
03/08/2021, 4:49 PMinitialize: function (options) {
this.model = options.model;
this.model.on('change', function () {
this.render();
}, this)
}
changeCart: function (e) {
let self = this;
let data = {'customerId' : '1234'};
this.model.save(data).done(function (result) {
self.model.set({'currentSelection': result.internalid});
});
}
Steve Goldberg
03/08/2021, 5:09 PMKearobi
03/08/2021, 6:27 PMchangeCart: function (e) {
let self = this;
let data = {'customerId' : '1234'};
this.model.save(data).done(function (result) {
self.parentView.render();
});
}
Steve Goldberg
03/08/2021, 6:47 PMinitialize
? I don't see how your first changeCart
code is worked around by the second one.
Perhaps it would be helpful if you could just describe what it is you're trying to doKearobi
03/08/2021, 6:53 PMSteve Goldberg
03/08/2021, 7:04 PMSteve Goldberg
03/08/2021, 7:06 PMinitialize: function (options) {
console.log('initialize called');
this.model = options.model;
this.model.on('change', function () {
console.log('model changed, render called');
this.render();
}, this)
}
changeCart: function (e) {
console.log('changeCart called');
let self = this;
let data = {'customerId' : '1234'};
this.model.save(data).done(function (result) {
console.log('model saved called');
self.model.set({'currentSelection': result.internalid});
});
}
Steve Goldberg
03/08/2021, 7:07 PMKearobi
03/08/2021, 7:08 PMKearobi
03/08/2021, 7:13 PMSteve Goldberg
03/08/2021, 7:17 PMthis.model.on('change', function () {
console.log('model changed, render called');
this.render();
}, this)
So, please, tell me what exactly is not working. For example: "this is not being triggered" or "it is being triggered but this.render()" is not workingKearobi
03/08/2021, 7:20 PMSteve Goldberg
03/08/2021, 7:24 PMthis.model.on('change', this.render, this);