Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-01-2013, 09:39 PM   PM User | #1
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
Question ui.combobox: Enter key causing problems

Hello, everyone.

I have a form that is used to filter tasks (the page default is "everything"; you can type in either "Application" or "Customer" fields and the autosuggest/autofill starts to populate the respective field.)

The submit button prevents the default form submit and does the submit via AJaX. So far, this is working quite nicely, IF the user clicks on or highlights a suggestion.

However, should the user hit the enter key without highlighting one of the suggestions, the selections disappear and the field is left with just the letters that the user has typed, thus far, and submits the form (bypassing the preventDefault() command), and the next thing I see is the whole page is replaced by just the form.

If I could figure it out, I suppose I could put an event handler that will ignore the Enter key; but this is the first time I've used ui.combobox, and I'm not sure what to do.

Any thoughts?

Thank you,
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 02-02-2013, 02:33 AM   PM User | #2
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,335
Thanks: 13
Thanked 207 Times in 207 Posts
DanInMa is on a distinguished road
sounds like you've done the classic mistake of binding your desired ajax functions to the submit button itself.

Instead of doing that, bind it the forms submit event instead. http://api.jquery.com/submit/


Code:
$("#element").submit(function(e){
e.preventDefault();
//do my ajax submittal etc here
});
- The idea is anything that fires the forms submit event , will be handled the way you intended.
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users

Last edited by DanInMa; 02-02-2013 at 03:40 AM..
DanInMa is offline   Reply With Quote
Old 02-04-2013, 01:40 PM   PM User | #3
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
As soon as my dev system boots up, I'll check the code. I don't think I've got it bound to the submit button.. actually, I don't think there IS a submit button, I think it's just an input type="button". But I'll report back what I've got.

UPDATE: As I suspected.. three select elements and an input type="button", no submit. Could the combobox be causing this?

Thanks,
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

Last edited by WolfShade; 02-04-2013 at 02:11 PM..
WolfShade is offline   Reply With Quote
Old 02-04-2013, 02:26 PM   PM User | #4
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
Well, I don't know exactly what is causing this, but I finally figured a solution.

In the form tag, I put onsubmit="return false;". Now it doesn't default submit and will still AJaX submit.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:27 AM.


Advertisement
Log in to turn off these ads.