【发布时间】:2012-11-01 13:21:05
【问题描述】:
我正在使用 jQuery 和可编辑插件创建内联可编辑表格。
到目前为止它运行良好,但只会在按 ENTER 后提交并保存到数据库。我在这里找到了一个线程,它帮助我在框之间切换,但按下 TAB 时它不会提交数据。
允许我在框之间切换的代码如下:
$('.editScheduleRow').bind('keydown', function(evt) {
if (evt.keyCode==9) {
var nextBox='';
var currentBoxIndex=$(".editScheduleRow").index(this);
if (currentBoxIndex == ($(".editScheduleRow").length-1)) {
nextBox=$(".editScheduleRow:first"); //last box, go to first
} else {
nextBox=$(".editScheduleRow").eq(currentBoxIndex+1); //Next box in line
}
$(this).find("input").blur();
$(nextBox).click(); //Go to assigned next box
return false; //Suppress normal tab
};
});
要使用 ENTER 提交,我使用这个:
$(".editScheduleRow").editable("../../includes/ajax/save-schedule-row.php", {
"submitdata": function ( value, settings ) {
return { fieldname: this.getAttribute('fieldname'), rowID: this.getAttribute('id') };
},
});
我还发现了一个带有建议的线程,但它对我不起作用:jEditable submit on TAB as well as ENTER
如果您需要更多信息,请告诉我。
【问题讨论】: