English 中文(简体)
JQuery Autocomplet 问题
原标题:JQuery Autocomplete Problem
  • 时间:2010-12-02 11:15:39
  •  标签:
  • jquery-ui

我在我的联合人民党中使用JQuery UI Autocomplete。 每当用户钥匙性质时,即要求服务器和将数据作为“JSON”和装饰物。

It s working fine. But Whenever i typed the same character as previous term. It s not populating any values.

For eg., 首先,它列出起算要素。 我有提纲重新确定汽车完成器的内容。 重新分类后,如果是同一种特性,那么它就没有显示什么。

我的法典如下:

var cache = {};

   $("#Name").autocomplete({  
             source: function(req, add){
      if (req.term in cache) {
                 add(cache[req.term]);
                 return;
             }
     $.getJSON("/store/StockManagement?action=getMedicinesStock",req, function(data) {  
                  var medicines = [];  
                  $.each(data, function(i, val){  
                   medicines.push(val.name + "," + val.code);
             });

             cache[req.term] = medicines;  
             add(medicines);  
         });  
     },select: function(e, ui) {  
         var medicine = ui.item.value;
         $( #Code ).val(medicine.split(",")[1]);
         setTimeout(function(){
             var med = $( #Name ).val();
             $( #Name ).val(med.split(",")[0]);
         },500);
         }
     });
问题回答
// Taken from jquery-ui-1.8.4.custom.min.js
if (a.term != a.element.val()) { // *** THE MATCH IS HERE
    //console.log("a.term != a.element.val(): "+a.term+", "+a.element.val());
    a.selectedItem = null;
    a.search(null, c) // *** SEARCH IS TRIGGERED HERE
}

我只是评论了情况。 如今,它被处以罚款。





相关问题
Using jQuery Plugins with Wordpress

Having a bit of trouble using jQuery plugins (Superfish, jQuery UI, etc) using Wordpress. Everything works fine in my plain non-Wordpress site, but Wordpress seems to conflict with JQuery. There must ...

Jquery TableSorter 2.0 - Revert Sort order

All, I am using the JQuery TableSorter Plugin. The table sorts fine for the selected columns. Consider that when the page loads, there is no sorting taking place. Now, if the table is sorted by one ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

热门标签