Feels like requestAutocomplete should return a Future (
http://dom.spec.whatwg.org/#futures) rather than 'autocomplete' & 'autocompleteerror'
Eg, instead of
button.addEventListener('click', function(){
form.requestAutocomplete();
});
// see details on event handling below
form.addEventListener('autocomplete', function(){
// successful rAc
// Call your client-side form validation logic here, if you have any.
form.submit(); // trigger submit
});
form.addEventListener('autocompleteerror', function(){
// event.reason is one of "cancel", "invalid" or "disabled".
// handle error...
});
The equivalent would be:
button.addEventListener('click', function() {
form.requestAutocomplete().then(function() {
// successful rAc
// Call your client-side form validation logic here, if you have any.
form.submit(); // trigger submit
}, function(reason) {
// reason is one of "cancel", "invalid" or "disabled".
// handle error...
});
});
All future async succeed/fail methods should be / are heading in this direction.
Cheers,
Jake.