需要Gmail的类似functionailty - jQuery的自动完成,包括姓名和电子邮件地址 - 字符串搜索 [英] need gmail like functionailty - jquery autocomplete to include names and email addresses - in string searching

查看:505
本文介绍了需要Gmail的类似functionailty - jQuery的自动完成,包括姓名和电子邮件地址 - 字符串搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我问这个问题,回来使用jquery为自动完成一个伟大的解决方案:

<一个href=\"http://stackoverflow.com/questions/1297518/need-a-good-way-for-user-to-select-to-for-email-sending\">http://stackoverflow.com/questions/1297518/need-a-good-way-for-user-to-select-to-for-email-sending

解决方案是使用下面的语法:

  $(#suggest3)。自动完成(的someArray,{
    多:真,
    mustMatch:真实,
    自动填充:真

});

我现在有电子邮件地址列表中自动完成,我需要把它一步映射到一样的功能的Gmail在那里我有真实的名称,并在列表中的邮件地址都因此用户可以输入名称或电子邮件地址,它会找到条目:

所以,名单将与此类似,用户可以通过键入搜索杉杉。或者emailAdd ......

 第一个最后&LT; EMAILADDRESS&GT;
First1 Las1t&LT; emailAddress1&GT;
First2 Last2&LT; emailAddress2&GT;


解决方案

等一下...你看演示?我认为它已经不正是这一点。举例来说,如果我输入for或JAP进入电子邮件领域,同一个人显示出来:Fornelia马可尼(用JAP是她的电子邮件地址的一部分)。这里是code,使这一点。

  $(#thickboxEmail)。自动完成(电子邮件,{
minChars:0,
宽度:310,
matchContains:真实,
highlightItem:假的,
formatItem:函数(行,我,最大,期限){
返回row.name.replace(新的RegExp((+长期+),GI),&LT;强&GT; $ 1 LT; / STRONG&gt;中)+&LT; BR&GT;&LT;跨度风格='字体大小:80%;'&GT;电子邮件:放大器; LT; + row.to +与&amp; GT;&下; /跨度&gt;中;
},
formatResult:函数(行){
返回row.to;
}
});

名称电子邮件对的数组是这样的:

  VAR电子邮件= [
    {名:小飞侠,以:peter@pan.de},
    {名:莫莉,以:molly@yahoo.com}
];

I recently asked this question and got back a great solution using jquery for autocomplete:

http://stackoverflow.com/questions/1297518/need-a-good-way-for-user-to-select-to-for-email-sending

The solution was to use this syntax:

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

});

i now have autocomplete on a list of email addresses and i need to take it one step further to map onto gmail like functionality where i include both the "real" name and the email address in the list so users can enter either the name or the email address and it will find the entry:

So the list would look similar to this and the user can search by typing "Firs . . ." or "emailAdd..."

"First Last" <emailAddress>   
"First1 Las1t" <emailAddress1>   
"First2 Last2" <emailAddress2>

解决方案

Wait a second.. Did you look at the demo? I think it already does exactly this. For instance, if I type in "for" or "jap" into the e-mail field, the same person shows up: Fornelia Marconi (with "jap" being part of her e-mail address). Here is the code that enables 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;
	}
});

The array of name-e-mail pairs looks like this:

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

这篇关于需要Gmail的类似functionailty - jQuery的自动完成,包括姓名和电子邮件地址 - 字符串搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆