JQuery Autocomplete Problem -
i using jquery ui autocomplete in jsp. whenever user keys character, made request server , data json , load pulgin.
it's working fine. whenever typed same character previous term. it's not populating values.
for eg., first typed p, lists p starting elements. have button reset text content of autocompleter. after reset, if typing same character p, doesn't show anything.
my code follows,
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 jquery-ui-1.8.4.custom.min.js if (a.term != a.element.val()) { // *** match here //console.log("a.term != a.element.val(): "+a.term+", "+a.element.val()); a.selecteditem = null; a.search(null, c) // *** search triggered here }
i commented condition. it's works fine.
Comments
Post a Comment