由于某种原因,jQuery UI的自动完成已停止为我工作。我得到了与this webpage中描述的相同的错误。jQuery UI自动完成已停止工作
我从下面的网页复制了查询的内容,希望这里的某个人能够回答它。
谢谢!
我使用Jquery UI Autocomplete
来获取名称列表。但由于某些原因,我得到一个错误:
$('#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。
我将不胜感激任何形式的帮助。
它来自jQuery UI 1.8.1文件,特别是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节未定义。另外需要注意的是它甚至不发送请求。我在想这可能是我的焦点功能。
.focus(function() { $(this).val('');
但事实并非如此。 谢谢你的帮助。
您应该标记自己的答案作为答案。另外,这种情况通常会因为返回的数据没有未引用的引号而中断。 – tomdemuyt 2010-06-24 20:50:55
我不确定我明白你的第二句话是什么意思。 我一定会举出我自己的答案,显然我不能接受我自己的答案两天。谢谢! – 2010-06-24 22:54:24