Skip to content

Commit

Permalink
Occasionally an invalid result can be displayed when enter key is used
Browse files Browse the repository at this point in the history
for selection - TRUNK-3923
  • Loading branch information
wluyima committed Mar 8, 2013
1 parent 684fa13 commit 85245c0
Showing 1 changed file with 18 additions and 20 deletions.
Expand Up @@ -613,6 +613,24 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler,
_handleResults: function(searchText, curCallCount) {
var self = this;
return function(results) {
//Don't display results from delayed ajax calls when the input box is blank or has less
//than the minimum characters, this can arise when user presses backspace relatively fast
//yet there were some intermediate calls that might have returned results
var currInput = $j.trim($j("#inputNode").val());
if(currInput == '' && !self.options.doSearchWhenEmpty){
if($j('#pageInfo').css("visibility") == 'visible')
$j('#pageInfo').css("visibility", "hidden");
if($j('#spinner').css("visibility") == 'visible')
$j("#spinner").css("visibility", "hidden");
$j(".openmrsSearchDiv").hide();
return;
}

if(curCallCount && self._lastCallCount > curCallCount) {
//stop old ajax calls from over writing later ones
return;
}

if(results["notification"])
$j(notification).html(results["notification"]);

Expand All @@ -635,26 +653,6 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler,
spinnerObj.css("visibility", "hidden");
loadingMsgObj.html("");
}

if(curCallCount && self._lastCallCount > curCallCount) {
//stop old ajax calls from over writing later ones
return;
}

//Don't display results from delayed ajax calls when the input box is blank or has less
//than the minimum characters, this can arise when user presses backspace relatively fast
//yet there were some intermediate calls that might have returned results
var currInput = $j.trim($j("#inputNode").val());
if(currInput == '' && !self.options.doSearchWhenEmpty){
if($j('#pageInfo').css("visibility") == 'visible')
$j('#pageInfo').css("visibility", "hidden");
if($j('#spinner').css("visibility") == 'visible')
$j("#spinner").css("visibility", "hidden");
$j(".openmrsSearchDiv").hide();
if(currInput.length > 0)
$j("#minCharError").css("visibility", "visible");
return;
}

self._doHandleResults(matchCount, searchText);

Expand Down

0 comments on commit 85245c0

Please sign in to comment.