-
-
Save Tomasz-Silpion/1fa96be213ffade829110989a16c0cc3 to your computer and use it in GitHub Desktop.
Custom integration of post code anywhere
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pca.on("load", function (type, id, control) { | |
control.listen("populate", function (address) { | |
console.log('here'); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Replace key with pca key | |
// Refer to documentation http://www.pcapredict.com/capture-plus/reference/2.20/pca.Address.html#Options | |
var options = {key: 'XXXX-XXXX-XXXX-XXXX', filteringMode: 'Address'}; | |
if (typeof pcakey !== 'undefined') options.key = pcakey; | |
// For field bindings refer to documentation http://www.pcapredict.com/capture-plus/reference/2.20/pca.Address.html#Binding | |
// Field modes refer to documentation http://www.pcapredict.com/capture-plus/reference/2.20/pca.html#fieldMode | |
var fields = [ | |
{element:'postcode', field: "{PostalCode}", mode: 3}, | |
{element:"buildingNum", field: "{BuildingNumber}", mode: 2}, | |
{element:"line1", field: "{Street}", mode: 2}, | |
{element:"line2", field: "{Line2}", mode: 2}, | |
]; | |
pca.ready(function() { | |
// Create a new address field | |
control = new pca.Address(fields, options); | |
// Listen to events | |
control.listen('populate', function() { | |
// This function get called when an address has been selected | |
console.log('Populated Event'); | |
}); | |
// Change result autocomplete line format | |
var formatLine = pca.formatLine; | |
pca.formatLine = function (item, format) { | |
var formatResult = formatLine(item, format); | |
return formatResult.replace('Addresses', 'Places'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment