Skip to content

Commit

Permalink
search.js: only load on certain input
Browse files Browse the repository at this point in the history
  • Loading branch information
chherbst committed Jul 5, 2010
1 parent 3ac073c commit 60ac3f2
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions web/js/search.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
var doLoad = false;
var oldValue;

function doAjaxCall( value, action ) {
//alert('got argument:' + value+ ':' + action );
$('#loader').show();
$('#anlagen').load(
action + ' #anlagen',
{ query: value + '*' },
function() { $('#loader').hide(); }
);
doLoad = false;
}

$(document).ready(function()
{
//$('.search input[type="submit"]').hide();

$('#search_keywords').keyup(function(key)
{
if (this.value.length >= 3 || this.value == '')
if ( key.which != '8' && key.which != '46' && !doLoad )
return;
if ( (this.value.length >= 3 || this.value == '' ) &&
oldValue != this.value )
{
$('#loader').show();
$('#anlagen').load(
$(this).parents('form').attr('action') + ' #anlagen',
{ query: this.value + '*' },
function() { $('#loader').hide(); }
);
oldValue = this.value;
doAjaxCall(this.value,
$(this).parents('form').attr('action'));
}
});

$('#search_keywords').keypress(function(key)
{
if (this.value.length >= 2)
doLoad = true;
});
});

0 comments on commit 60ac3f2

Please sign in to comment.