jQuery UI 自动完成停止工作

发布于 2024-09-06 14:40:57 字数 3200 浏览 1 评论 0原文

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

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

谢谢!

我正在使用 Jquery UI Autocomplete 来获取姓名列表。但由于某种原因,我收到错误:

alt text

$('#repName').removeAttr('readonly').focus(function () {
                   $(this).val('');
               }).自动完成({
                   来源:函数(请求,响应){
                       tagId = $('#TagId').val();
                       $.ajax({
                           url: '/Developement/GetRepName', 类型: 'POST', 数据类型: 'json',
                           数据:{ searchText:request.term,maxResults:10,tagId:tagId },
                          成功:函数(数据){
                              响应($.map(数据,函数(项目){
                                  返回 {
                                      标签:项目.名称,
                                      值:item.RepId,
                                      id: 项目.RepId
                                  }
                              }))
                          }
                      })
                  },
                  选择:函数(事件,用户界面){
                      CommissionAllicationModifications(ui.item.id, 0, 'A');
                  }
              });

我不知道为什么会发生这种情况。 我正在使用 Jquery UI 1.8.1。

我将不胜感激任何形式的帮助。

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

<前><代码> .menu({ 焦点:函数(事件,ui){ var item = ui.item.data("item.autocomplete"); if (false !== self._trigger("focus", null, { item: item })) { // 如果是按键事件,则使用值来匹配输入中最终出现的内容 if (/^key/.test(event.originalEvent.type)) { self.element.val(item.value); } } }, 选择:函数(事件,ui){ var item = ui.item.data("item.autocomplete"); if (false !== self._trigger("select", event, { item: item })) { self.element.val(item.value); } self.close(事件); // 仅在焦点丢失时触发(单击菜单) var previous = self.previous; if (self.element[0] !== doc.activeElement) { self.element.focus(); self.previous = 上一个; } self.selectedItem = 项目; }, *模糊:函数(事件,ui){ * if (self.menu.element.is(":visible")) { * self.element.val(self.term); * } * } }) .zIndex(this.element.zIndex() + 1) // jQuery bug #5781 的解决方法 http://dev.jquery.com/ticket/5781 .css({ 顶部: 0, 左侧: 0 }) 。隐藏() .data(“菜单”);

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

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

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

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.

Thanks!

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

alt text

$('#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');
                  }
              });

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.

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

勿挽旧人 2024-09-13 14:40:57

事实证明,我包含了一个定义 $.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.

相对绾红妆 2024-09-13 14:40:57

您使用什么版本的 jQuery 核心?

我知道与 可见检测 相关且与 IE8。如果可能的话,您能否在测试机上升级到最新的 jQuery,看看是否可以解决您的问题?

如果您不想升级,您也可以尝试破解 jQuery(丑陋!) - 有了这个

if (self.menu.element.is(":visible"))

变成

if (!(self.menu. element.css('显示') == '无'))

What version of jQuery core are you using?

I know of a bug related to visible detection and related to IE8. If possible, can you upgrade to the most recent jQuery on a test machine and see if that solves your problem?

If you don't feel like upgrading, you could also try hacking jQuery (UGLY!) - with this:

if (self.menu.element.is(":visible"))

becomes

if (!(self.menu.element.css('display') == 'none'))

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文