Canada Post AddressComplete On "populate" Not Working
I'm trying to use Canada Post's Address Complete on my form as such var fields = [ { element: 'street_address', field: 'Line1' }, { elem
Solution 1:
I tried playing with the API and I couldn't get any events to fire on the addressComplete
object but the ready
event. However, since we have all ready constructed a control
instance, I just removed the load
listener and attached the populate
event handler directly to the control
object we constructed. This seemed to work.
//addressComplete.listen('load', function (control) {
control.listen('populate', function (address) {
// TODO: Handle populated address here.
});
//});
Solution 2:
I got error - Uncaught ReferenceError: control is not defined
Once the Canada Post JavaScript is loaded, then the control
instance is created - addressComplete.controls[0]
To listen to populate
event of the control:
addressComplete.controls[0].listen("populate", function (address) {
// TODO: Handle populated address here.
});
load()
and reload()
apis are also available.
addressComplete.controls[0].load();
addressComplete.controls[0].reload();
// destroy();
// load();
Post a Comment for "Canada Post AddressComplete On "populate" Not Working"