To give some background, PCA Predict is a service whereby you start typing an address and it will autocomplete with suggestions and fill in the other address fields when you click on the correct address.
I'm having to do some extra work because where the fields get filled out by PCA Predict, it isn't saved to the model (it just exists in the view) (by adding a space character to the field will make it save).
I have it working on the first attempt, but if I navigate to a different module, then come back, model is null and I get an error.
({
// CustomRecord View (base)
extendsFrom: 'AccountsRecordView',
initialize: function (options) {
this._super('initialize', [options]);
},
render: function(){
this._super('render');
},
editClicked: function() {
this._super('editClicked');
var self = this;
setTimeout(function() {
pca.load();
pca.on("load", function (type, Id, control) {
control.listen("populate", function (address) {
self.model.set('shipping_address_city', address.City);
//self.model is null second time round.
});
});
}, 2000);
}
})
Why is self.model null!? All the other properties of self is available, all apart from model, which is set to null!