在TAB和ENTER上进行jEditable提交 [英] jEditable submit on TAB as well as ENTER

查看:153
本文介绍了在TAB和ENTER上进行jEditable提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只要用户按ENTER离开输入,我的jEditables就能正常工作.但是,如果用户单击TAB,则不会发布更改.这是正确且有据可查的行为.

My jEditables work fine as long as the user hits ENTER to leave the input. If the user hits TAB, however, the changes are not posted. This is the correct and documented behavior.

我希望TAB像ENTER一样工作.我不需要影响任何其他jEditables,只需将当前活动的jEditables发送回去,就好像按下ENTER键一样.

I'd like TAB to work just as ENTER does. I don't need to affect any other jEditables, just get the currently active one to post back as if ENTER had been hit.

除了将keydown处理程序绑定到jEditable控件之外,是否有其他方法可以做到这一点?

Is there any way to do this short of binding an keydown handler to the jEditable controls?

如果我确实必须提供一个keydown处理程序,是否可以通过任何方式以编程方式告诉jEditable控件发布自身,而无需从该控件中提取id和值?

If I do have to provide a keydown handler, is there any way to programmatically tell a jEditable control to post itself without extracting the id and value from the control?

推荐答案

您可以在.editable()之后绑定一个click事件,因此它会在jEditable事件(设置表格)之后触发.然后将keydown事件绑定到侦听TAB键的文本框.因此,假设您正在处理文本框,则可以执行以下操作:

You could bind a click event after .editable(), so it is triggered after the jEditable's event, which set up the form. Then bind a keydown event to the text box that listens to the TAB key. So, assuming you're dealing with a text box, 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();
    });
});

查看实际操作: http://jsfiddle.net/william/6VUHh/5/.

这篇关于在TAB和ENTER上进行jEditable提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆