没有数据建议的jQuery的Ajax自动完成

时间:2012-06-08 10:55:16

标签: jquery autocomplete

我有

var autocompleteProfessionals = that.container.find("#ProfessionalsName");

    autocompleteProfessionals.each(function () {
        $(this).autocomplete({
            serviceUrl: '../Professionals/FindProfessionals',
            minChars: 2,
            delimiter: /(,|;)\s*/,
            maxHeight: 200,
            width: 400,
            zIndex: 9999,
            deferRequestBy: 100,  
            onSelect: function (value, data) {
                that.container.find("#IdProfessionals").val(data.IdProfessionals);

            }
        });
    }
    );

当我找到具有自动填充功能的专业人士并选择他时,我会设置他的身份证明。然后我从字段中删除此专业名称并输入不存在的专业名称。 我有问题,因为IdProfessionals是有效的,但ProfessionalsName不是。

当我从文本字段中删除专业名称时,如何从IdProfessionals中删除值?

1 个答案:

答案 0 :(得分:0)

http://jqueryui.com/demos/autocomplete/#event-search

var autocompleteProfessionals = that.container.find("#ProfessionalsName");

autocompleteProfessionals.autocomplete({
   serviceUrl: '../Professionals/FindProfessionals',
   minChars: 2,
   delimiter: /(,|;)\s*/,
   maxHeight: 200,
   width: 400,
   zIndex: 9999,
   deferRequestBy: 100,  
   onSelect: function (value, data) {
     that.container.find("#IdProfessionals").val(data.IdProfessionals);
   }
   search: function(event, ui) {
     $('#IdProfessionals').val('');
   } 
 });