1

我有

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);

            }
        });
    }
    );

当我找到具有自动完成功能的专业人士并选择他时,我设置了他的 ID。然后我从字段中删除这个专业名称并输入不存在的专业名称。我这里有问题,因为 IdProfessionals 是有效的,但 ProfessionalsName 不是。

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

4

1 回答 1

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('');
   } 
 });
于 2012-06-08T11:02:56.340 回答