Jquery插件autocomplete自动补全插件一旦用上了mustMatch,会将文本框清空
要实现的效果是输入拼音简写,然后显示名称,我现在实现了这个效果,但是需要只能让选择的出现在文本框中,就想到了它自带的属性mustMatch(如果设置true,autoCo...
要实现的效果是输入拼音简写,然后显示名称,我现在实现了这个效果,但是需要只能让选择的出现在文本框中,就想到了它自带的属性mustMatch(如果设置true,autoComplete只会允许匹配的结果出现在输入框,所有当用户输入的是非法字符时将会得不到下拉框),但是加上这个问题就来了,当我输入拼音简写的时候,能正常检索出下来框并且显示,但是一旦选取一个的时候,会出现在文本框上 ,但是会很快被清空,我查了一下,是因为我一旦加上了mustMatch属性,当选择的时候会从新跳转一遍Action,当然这次传到后台的不是拼音简写了,是选择项的中文名字了,所以没有找到数据,很快被清空了,我不明白为什么,有熟悉这个的吗,求解答,如何解决,用的异步,后台action代码就是返回的json字符串到前台页面,格式为
var list = [
{id:'110000',name:'北京',pName:'null'},
{id:'110100',name:'北京市',pName:'null'},
{id:'110101',name:'东城区',pName:'null'},
{id:'110102',name:'西城区',pName:'null'},
{id:'110103',name:'崇文区',pName:'null'},
{id:'110104',name:'宣武区',pName:'null'},
{id:'110105',name:'朝阳区',pName:'null'},
{id:'110106',name:'丰台区',pName:'null'},
{id:'110107',name:'石景山区',pName:'null'},
{id:'110108',name:'海淀区',pName:'null'},
{id:'990106',name:'asdfa',pName:'null'},
{id:'990105',name:'caoyangqu',pName:'null'},
{id:'990101',name:'朝阳区测试2',pName:'null'},
{id:'990104',name:'北京xcv',pName:'null'},
{id:'990102',name:'北京fsdf',pName:'null'},
{id:'990103',name:'北京sdfd',pName:'null'}
];
求高人解答 展开
var list = [
{id:'110000',name:'北京',pName:'null'},
{id:'110100',name:'北京市',pName:'null'},
{id:'110101',name:'东城区',pName:'null'},
{id:'110102',name:'西城区',pName:'null'},
{id:'110103',name:'崇文区',pName:'null'},
{id:'110104',name:'宣武区',pName:'null'},
{id:'110105',name:'朝阳区',pName:'null'},
{id:'110106',name:'丰台区',pName:'null'},
{id:'110107',name:'石景山区',pName:'null'},
{id:'110108',name:'海淀区',pName:'null'},
{id:'990106',name:'asdfa',pName:'null'},
{id:'990105',name:'caoyangqu',pName:'null'},
{id:'990101',name:'朝阳区测试2',pName:'null'},
{id:'990104',name:'北京xcv',pName:'null'},
{id:'990102',name:'北京fsdf',pName:'null'},
{id:'990103',name:'北京sdfd',pName:'null'}
];
求高人解答 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询