看看我的代码:
$(".field").editable("http://"+document.location.host+"/index.php/welcome/update_record",
{
event : "mouseover",
style : "inherit",
callback: function(value, settings)
{
//Some code
}
}
但我有一些问题 - 这段代码对我有用,因为它通过“输入”按钮捕获点击。但现在我需要将字段类型更改为“textarea”:
$(".field").editable("http://"+document.location.host+"/index.php/welcome/update_record",
{
type : "textarea",
event : "mouseover",
style : "inherit",
callback: function(value, settings)
{
//Some code
}
}
现在它不起作用 - 即回调函数从未执行过。请告诉我,我需要有textarea字段并抓住按Enter的事件。
答案 0 :(得分:1)
如果您想按Enter键进行回调,可以执行以下操作:
$('#example').keyup(function(e) {
if (e.which == 13) {
$('#example').trigger('custom');
}
});
然后在jEditable中捕获处理程序的'custom'事件..
我不会称之为最佳做法,但用户习惯于使用文本区域中的输入按钮添加多行。也许你也可以添加一个按钮 - 我相信jEditable可以自动添加一个“保存”按钮..
在这个问题中 - jquery jeditable without OK and Cancel Buttons - 他们使用模糊事件,这对我来说更有意义..
答案 1 :(得分:0)
我建议同时检查ctrl和Shift键,并防止默认行为是一种:
$(this).bind('keydown', function () {
if (event.keyCode === 13 && !event.shiftKey && !event.ctrlKey) {
event.preventDefault();
$(this.form).submit(); // Or whatever
return false;
}
})