I have a similar problem where i want to submit a AJAX form through its button click event because the AJAX onclick handler is added dynamically through RichFaces. I have two different forms and tried to define a keypress handler for my input fields as follows -- jQuery(".search input:text").keypress(function(e) { if (e.which == 13 || e.keyCode == 13) { // ENTER-Key jQuery(".btnSearch").click(); } }); --
The curiousity now is that the code works on the form where i have 3 input text fields and submits the form via AJAX but not on the one with just one input field. There the form is submitted via POST ... :-/ Any ideas? On Jul 22, 5:10 pm, Will Moffat <[EMAIL PROTECTED]> wrote: > Hi guys, thanks for the replies, and sorry for the delay in > responding. > > I see that didn't clearly state the context of my problem. > > I want to use jQuery to simulate mouse clicks for many different HTML > elements (not just form submit buttons). My test shows that > jQuery.click() doesn't give same results as a real click. > > Here's the code from my test: > > <form action="javascript:alert('browser submit handler')"> > ... > <input type='submit' value="Cook hamster"></input> > </form> > $('form').submit(function() { alert('jquery submit handler'); }); > > $('input[type=submit]').click(); > > So when click() is called I expect both jquery and browser handlers to > fire, but in fact only the browser handler fires. > A real mouse click causes both to fire. > > Can anybody explain this difference? Should I file a bug? > regards, > --Will