Need gmail as functionailty - jquery autocomplete to include names and email addresses - in string search

I recently asked this question and returned a great solution using jquery to autocomplete:

Need a good way for the user to select "To" to send an email

The solution was to use this syntax:

$("#suggest3").autocomplete(someArray, { multiple: true, mustMatch: true, autoFill: true 

});

Now I have autocomplete in the list of email addresses, and I need to take one more step to map to gmail functions, in which I include both the "real" name and the email address in the list so that users can enter either a name or address email and it will find the entry:

Thus, the list will look something like this, and the user can perform a search by typing "Firs ...". or "emailAdd ..."

 "First Last" <emailAddress> "First1 Las1t" <emailAddress1> "First2 Last2" <emailAddress2> 
+6
jquery search autocomplete
source share
2 answers

Wait a second .. Have you watched the demo ? I think this is already doing just that. For example, if I type β€œfor” or β€œjap” in the email field, the same person appears: Fornelia Marconi (with β€œjap” being part of her email address). Here is the code that allows this.

 $("#thickboxEmail").autocomplete(emails, { minChars: 0, width: 310, matchContains: true, highlightItem: false, formatItem: function(row, i, max, term) { return row.name.replace(new RegExp("(" + term + ")", "gi"), "<strong>$1</strong>") + "<br><span style='font-size: 80%;'>Email: &lt;" + row.to + "&gt;</span>"; }, formatResult: function(row) { return row.to; } }); 

An array of name and email pairs is as follows:

 var emails = [ { name: "Peter Pan", to: " peter@pan.de " }, { name: "Molly", to: " molly@yahoo.com " } ]; 
+6
source share

Fyi. This autocomplete plugin is no longer under development, for a note on the website:

http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

JQuery Plugin: Autocomplete

Note (2010-06-23): This plugin is deprecated and is no longer developed. Its successor is part of the jQuery user interface, and this migration guide explains how to get from this plugin to a new one. This page will remain the same as for reference, but will not be updated anymore.

So, if you want, you can use the following comparable example from jQueryUI autocomplete:

http://jqueryui.com/demos/autocomplete/#multiple-remote

I personally prefer jQuery Tools to jQueryUI /, but at this point they do not offer an autocomplete plugin ... well, good.

+3
source share

All Articles