Clicking the Find-button displays content nicely using AHAH hitting the Enter key however, takes me to a new page. I would like the hitting Enter to do the same as clicking the button. Am I missing something? Thanks.
Clicking the Find-button displays content nicely using AHAH hitting the Enter key however, takes me to a new page. I would like the hitting Enter to do the same as clicking the button. Am I missing something? Thanks.
Comments
Comment #1
danielb commentedDrupal's Forms API AHAH implementation only works with buttons AFAIK. Putting it on other elements so that the enter button would have an effect has caused some really dodgy behaviour.
It might be possible to integrate some 3rd party jquery or something to make it happen? Don't know.
Comment #2
perandre commentedThanks! Hm. Any help here: http://www.abdevelopment.ca/blog/fixing-enter-key-ahah-forms ?
Comment #3
gundarx commentedI used the following JS code in my theme to do this. AjaxComplete callback is to rebind the object if the AHAH feature is used.
Comment #4
danielb commentedHas anyone had any success with the above code? It seems to only work if you:
1) Are using an autocomplete element.
2) You are not using 'submit upon selection'.
3) Select the autocomplete suggestion with your MOUSE
4) For some unfathomable reason you then press 'enter' on a KEYBOARD.
:(
Besides, there is nothing actually wrong about the way it currently works. If you 'tab' over to the submit button and press enter, it works perfectly - that is the correct way to use it.
Comment #5
danielb commentedok so I didn't see 'auto complete' in the issue title, that explains 1).
I also noticed it assumes the submit button has an ID of #edit-submit which it often doesn't.
Comment #6
danielb commentedI've also looked into using ahah_helper as suggested on the page linked in post #2, but that module didn't appear to do anything :/ I'd ask on their issue queue but it looks like nobody has answered issues there in a while.
Comment #7
bento_box commentedI have a similar problem. I've turned off the autocomplete feature by simply using a regular text box with the "find" button turned on. If I click the find button with the mouse, ahah worked fine. If I hit return after entering my search text, then it opens in a new page. I'll try out some of hte code above and see if it works for me.
Comment #8
nightowl77 commentedWhoohoo!! I got it to work!! :)
2 Changes: e.keyCode instead of e.which and trigger('click') instead of trigger ('mousedown').
Thank you gundarx - without your code I wouldn't have been able to even *start* figuring this out.
Question: Is it possible to make this part of the finder project? I'm not an expert on jquery, so I wouldn't know if there are some potential conflicts with other parts of the js code.
Comment #9
gundarx commentedNo problem. I'm happy to contribute where I can :)
Comment #10
danielb commentedThe code assumes there is only one finder form on a page, and it assumes things about there being a button and what the properties of that button are, and nobody has stated clearly under what circumstances this script would be added to the output. I think it needs work or at least these things should be addressed.
Comment #11
danielb commented