On Wed, Feb 20, 2013 at 10:04 AM, Chris Moules christopher@gms.lu wrote:
Hello,
Well I did spend a bit of time following the function calls in app.js.src and that lead me to: program/steps/mail/autocomplete.inc
It looks like this search was not intended to be used outside of email composition, which is OK but does not fit this use case.
As a simple but inelegant workaround, a simple regex on the data seems to work:
rcmail.init_address_input_events(row_input, ""); row_input.blur(function() { row_input.val(function(e, val) { return val.replace(/.*<(\S*)>.*/, "$1"); }); });
Is there a better approach, that is obvious to anyone versed in this part of Rouncdube, to solve this in a cleaner fashion?
We already use autocompletion in some plugins. For example in the ACL plugin: https://github.com/roundcube/roundcubemail/blob/master/plugins/acl/acl.js#L1... or in the Kolab calendar plugin: http://git.kolab.org/roundcubemail-plugins-kolab/tree/plugins/calendar/calen...
After initializing the input field with rcmail.init_address_input_events() you can catch the selected address using an event listener: rcmail.addEventListener('autocomplete_insert', function(e){ /* do something with e.insert */ });
However, you still have to post-process the value with some regex to fit the purpose of your plugin.
Regards, Thomas