Both answers are excellent. Two different approaches, both teach me
something new.
Thank you both
Chip
I can't believe that I didn't notice that.
On Mon, Oct 26, 2009 at 11:58 AM, Michel Belleville
wrote:
> Forms already submit when the enter is pressed, though they can also submit
> when an input submit button is pressed. Binding the ajax call to the submit
> events covers both scenarios, plus i
Forms already submit when the enter is pressed, though they can also submit
when an input submit button is pressed. Binding the ajax call to the submit
events covers both scenarios, plus it seems to me a lot less complicated
than catching the key13 event.
Michel Belleville
2009/10/26 brian
>
>
Forget about catching the enter key press, catch the form submit instead,
make it do the ajax call and prevent default response, and execute the same
ajax call on change :
var ajax_search = function() {
// whatever AJAX you want ...
};
$('#search').change(function(event) {
ajax_search();
})
.clos
Maybe something like this?
$("#search").change(doSearch($(this))).bind("keypress", function(e) {
if (e.keyCode == 13)
{
doSearch($(this));
return false;
}
});
function doSearch(el)
{
var vKeyword = el.val;
$.ajax({
type: "GET",
...
On Sun, Oct 25
5 matches
Mail list logo