When a user types into #pgSearch
to filter a list, if there's no match, a .noresults
becomes visable.
Also, when there's no match, a form (#RequestRecipe
) should become visable as well. But it doesn't immediately when .noresults
appears. I need to press any extra key to trigger it. Also vice-versa: when I delete characters till the noresults
dissapears and the matches is displayed, but the form is still visible till I hit any extra key.
So my thought was to trigger a keypress. But it doesn't seem to work.
$(function(){
$('#pgSearch').keyup(function() {
$('#RequestRecipe #recipe').val($(this).val()); // copy #pgSearch to #recipe
$(this).trigger(jQuery.Event('keypress', {keyCode: 65})); // 65 is for testing. I think 16 (shift) or 29 (ArrowRight) is suitable
if($('.noresults').is(':visible')){
$('#RequestRecipe').slideDown('slow');
} else {
$('#RequestRecipe').slideUp('slow');
}
});
});
Any suggestion?
EDIT: I've uploaded a work-in-process version of my site where you can se what happens here : http://drinksta.thomaskile.me/
It's the search on the index-page.
When you star searching, the list is filtered using quicksearch
-plugin.
When there's no match, the .noresult
-row becomes visible (set to display: table-row;
.
When this happens, you nedd to press an extra key to trigger the show/hide on #RequestRecipe
.
Example:
you type "abc", the .noresult
is shown, but not the form. You then have to either keep writing, or just pess any given key, and it then shows...