jQuery UI自动完成功能停止工作 [英] jQuery UI Autocomplete stopped working

查看:98
本文介绍了jQuery UI自动完成功能停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,jQuery UI的自动完成功能已停止为我工作.我收到与此网页.

For some reason jQuery UI's autocomplete has stopped working for me. I get the same error as is described on this webpage.

我已经从下面的那个网页复制了查询的内容,希望这里的人能够回答它.

I've copied the content of the query from that webpage below, hoping that somebody here will be able to answer it.

谢谢!

我正在使用Jquery UI Autocomplete来获取姓名列表.但是由于某种原因,我遇到了一个错误:

I am using Jquery UI Autocomplete to get a list of names. But for some reason I am getting an error:

$('#repName').removeAttr('readonly').focus(function () {
                   $(this).val('');
               }).autocomplete({
                   source: function (request, response) {
                       tagId = $('#TagId').val();
                       $.ajax({
                           url: '/Developement/GetRepName', type: 'POST', dataType: 'json',
                           data: { searchText: request.term, maxResults: 10, tagId: tagId },
                          success: function (data) {
                              response($.map(data, function (item) {
                                  return {
                                      label: item.Name,
                                      value: item.RepId,
                                      id: item.RepId
                                  }
                              }))
                          }
                      })
                  },
                  select: function (event, ui) {
                      commissionAllicationModifications(ui.item.id, 0, 'A');
                  }
              });

我不知道为什么会这样. 我正在使用Jquery UI 1.8.1.

I have no clue why this is happening. I am using Jquery UI 1.8.1.

在此方面,我将不胜感激.

I would appreciate any kind of help on this.

它来自jQuery UI 1.8.1文件,特别是jQuery UI Autocomplete 1.8.1.

It is coming from the jQuery UI 1.8.1 file, specifically jQuery UI Autocomplete 1.8.1.

 .menu({
               focus: function (event, ui) {
                   var item = ui.item.data("item.autocomplete");
                   if (false !== self._trigger("focus", null, { item: item })) {
                       // use value to match what will end up in the input, if it was a key event
                       if (/^key/.test(event.originalEvent.type)) {
                           self.element.val(item.value);
                       }
                   }
               },
               selected: function (event, ui) {
                   var item = ui.item.data("item.autocomplete");
                   if (false !== self._trigger("select", event, { item: item })) {
                       self.element.val(item.value);
                   }
                   self.close(event);
                   // only trigger when focus was lost (click on menu)
                   var previous = self.previous;
                   if (self.element[0] !== doc.activeElement) {
                       self.element.focus();
                       self.previous = previous;
                   }
                   self.selectedItem = item;
               },
*                blur: function (event, ui) {
*                    if (self.menu.element.is(":visible")) {
*                        self.element.val(self.term);
*                   }
*               }
           })
           .zIndex(this.element.zIndex() + 1)
           // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
           .css({ top: 0, left: 0 })
           .hide()
           .data("menu");

这很奇怪,因为它在另一个项目中可以完美地工作.我注意到的是,当代码到达[starred]部分时,self.menu部分未定义.值得注意的另一件事是它甚至不发送请求.我当时以为这可能是我的重点功能.

It is weird though because this works flawlessly in another project. What I noticed is when the code hits the [starred] section the self.menu section is undefined. Another thing of note was that it doesn't even send the request. I was thinking that it might be my focus function.

.focus(function () {
     $(this).val('');

但事实并非如此. 谢谢你的帮助.

But it is not. Thank you for you help.

推荐答案

事实证明,我包括一个定义了$.fn.menu的插件,并且造成了严重破坏.我将其更改为$.fn.fg_menu,问题已解决.

It turns out that I included a plugin that defined $.fn.menu and this wrought havoc. I changed it to $.fn.fg_menu and the problem was resolved.

这篇关于jQuery UI自动完成功能停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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