Open arwystli opened 5 years ago
Hi Bob,
The input needs to be added to a form element and I think this may be the issue here. For example:
`
</div>`
Could you confirm if you have a form element on your site?
Thanks
Andy
Yes I can confirm that There is a form element on the site: `
The dropdown works as expected, it is only the validation that fails when that has been enabled, here is the js code that gets it working:
// w3w autosuggest
$("#edit-getlocations-what3words-search").w3wAddress({
debug: true,
lang: 'en',
//validation: false,
validation: true,
country_filter: 'gb',
api_end_point: '/myhelper_cb_w3w_as/',
multilingual: false,
results: 6
});
`
The api_end_point also works well, it returns a json string as requested.
It is only the validation that does not work when I use the proxy method, which I also use for the non-autosuggest examples. If I disable the api_end_point parameter and supply the key in the js then validation does work, although this does expose the key as we know :-)
I have added plenty of console.log statements to jquery.w3w-autosuggest-plugin.js but in the end could not figure out a solution. We've had a look at https://test.arwystli.net/getlocations_all demo and our autosuggest plugin is not wrapped in a
Hi, I am Bob Hutchinson and I have integrated what3words with a project of mine, https://www.drupal.org/project/getlocations I am trying to add the jquery autosuggest plugin to the getlocations project and have succeeded (but not yet committed) in getting it to work OK but when I try to add the proxy method (which I already use for the regular lookups) it fails to validate. If I disable validation it works but when I enable it the message "Please enter a valid 3 word address." switches off when an item is selected but then immediately switches back on again, even though the w3w string is valid and has been entered into the form input box. I have fetched and installed typeahead and validate separately, the problem also occurs with the bundled version. Looking at jquery.w3w-autosuggest-plugin.js and using console.log I can see that the variable lastValidatedSuccess remains false so isSuccess also remains false thus triggering the error message. I tried setting isSuccess to true in the if conditional at line 422 but that failed and as I am not sure what lastValidatedSuccess is for I decided it was time to contact the author. Just to reiterate, the proxy method itself works, fetches data and returns it as json to the browser where it is displayed immediately below the input box and selecting one puts it into the input box and when I appy that to the map it goes to the right place on the map. I can disable validation but it is a nice feature and I would like to have it enabled. There is a demo of getlocations with what3words enabled at https://test.arwystli.net/getlocations_all This does not yet have the autosuggest applied to it but uses the proxy method to fetch the data and apply it to the map.