Address Auto-Complete On Two Forms
How To Apply Address Auto-Complete to Multiple Forms on the Same Page
The clickToAddress
class can only be instantiated once. If you try to instantiate it twice, you will see the error "Uncaught Already initiated".
The class has an attach
method that allows you to integrate with extra address forms. You should use this when you want to integrate with two or more forms on the same page.
The method accepts on object containing the form fields you want to integrate with.
cc = new clickToAddress(config);
cc.attach({
search: 'search_field',
town: 'addr_town',
postcode: 'addr_postcode',
county: 'addr_county',
line_1: 'addr_line1'
});
cc.attach({
search: 'search_field-2',
town: 'addr_town-2',
postcode: 'addr_postcode-2',
county: 'addr_county-2',
line_1: 'addr_line1-2'
});