JEditable submit on TAB as well as ENTER

My jEditables work fine while the user press ENTER to leave the input. However, if the user presses TAB, the changes are not published. This is the correct and documented behavior.

I would like TAB to work the same as ENTER. I do not need to influence any other jEditables, just get the current activity to send the message back as if ENTER was pressed.

Is there a way to do this without binding the keydown handler to keydown controls?

If I need to provide a keydown handler, is there a way to programmatically tell the jEditable control a message about itself without extracting the identifier and value from the control?

+4
source share
1 answer

You can bind the click event after .editable() , so it fires after the jEditable event, which customizes the form. Then bind the keydown event to the text field that the TAB key is listening to. So, assuming you are dealing with a text field, you can do something like the following:

 $('.editable').editable('url', { ... }).click(function(evt) { $(this).find('input').keydown(function(event) { if (event.which == 9) //'TAB' $(this).closest('form').submit(); }); }); 

See this in action: http://jsfiddle.net/william/6VUHh/5/ .

+5
source

All Articles