Events
SelectionChangeEvent
Every time the user chooses something in Address Helper, the event selectionChangeEvent is fired. To listen for this event, use the following syntax:
diah.selectionChangeEvent.subscribe(function(){
// Check the result
});
Read more about the methods including the object getSelectedAddress() returns.
Example
diah.selectionChangeEvent.subscribe(function(){
// Check the result
});
Example implementation for dynamic styling of floor/flat
This example uses wrappers for floor and flat to better guide the user. Depending on the selected address the user might be prompted for more details (from the default skin)
diah.selectionChangeEvent.subscribe(function() {
var address = this.getSelectedAddress(),
completeWithoutFloors = this.isComplete() && address.floor == -1,
showFloor = address.streetNumber!=null && !address.streetNumber.ignoreHouseholds(),
showHousehold = showFloor && address.floor!=null && address.household != -1,
floorWrapper = $Q('.floorInputWrapper', element, true),
householdWrapper = $Q('.householdInputWrapper', element, true);
floorWrapper.style.display = 'none';
householdWrapper.style.display = 'none';
if (showFloor && !completeWithoutFloors) {
floorWrapper.style.display = 'inline-block';
householdWrapper.style.display = 'inline-block';
householdWrapper.style.opacity = showHousehold ? '1' : '.2';
}
}, this, true);
productSupportEvent
Checking for coverage (for the selected address) of an distributed product.
If distributionSupport-config is used, this event will trigger each time we have done a coverage check for the given product/customersystem.
To listen for this event, use the following syntax:
diah.productSupportEvent.subscribe(function(e, args){
var data = args[0];
// Check the data for:
// data.hasSupport
// data.hasKeyDeviation
// data.keyDeviation
// data.deliveryPlace
// data.distrDate
});