来自 AJAX 回调的 Jeditable CANCEL 回调? [英] Jeditable CANCEL callback from AJAX callback?

查看:34
本文介绍了来自 AJAX 回调的 Jeditable CANCEL 回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一些关于 Jeditable 插件的答案,以使用 AJAX 的回调函数使用完整的回调函数.

I see some answers for the Jeditable plugin to use a callback function from AJAX using complete callback function.

我知道Jeditable有SUBMIT按钮的回调函数,所以我想知道是否有办法让CANCEL按钮回调?我在插件文档上没有找到.

I know that the Jeditable has a callback function for the SUBMIT button, so I would like to know if there is a way to have a callback for the CANCEL button? I haven't found on the plugin docs.

感谢回复,

卡洛斯

PD.这是我从 AJAX 回调中看到的 COMPLETE 的来源:

PD. This is the source I see for COMPLETE from AJAX callback:

$("#editable_text").editable(submitEdit, { 
            indicator : "Saving...",
            tooltip   : "Click to edit...",
            name : "Editable.FieldName",
            id   : "elementid",
            type : "text",
});
function submitEdit(value, settings)
{ 
   var edits = new Object();
   var origvalue = this.revert;
   var textbox = this;
   var result = value;
   edits[settings.name] = [value];
   var returned = $.ajax({
           url: "http://URLTOPOSTTO", 
           type: "POST",
           data : edits,
           dataType : "json",
           complete : function (xhr, textStatus) 
           {
               var response =  $.secureEvalJSON(xhr.responseText);
               if (response.Message != "") 
               {
                   alert(Message);
               } 
           }
           });
   return(result);
 }

推荐答案

是的,有一个onreset"参数,在单击取消时调用,或者更一般地说,在 jEditable 将控件重置回被单击之前的状态之前.将此添加到您的代码中:

Yes, there is a "onreset" parameter that is called when clicking cancel, or more generally, before jEditable resets the control back to the state before it was clicked. Add this to your code:

$("#editable_text").editable(submitEdit, { 
    //...
    onreset: jeditableReset,
    //...
});

function jeditableReset(settings, original) {
   // whatever you need to do here
}

这记录在 jquery.jeditable.js 文件的标题中.

This is documented in the header of the jquery.jeditable.js file.

另一个注意事项 - 如果您不提交模糊(您似乎不在示例中),则 onreset 事件也会触发.

Another note - if you don't submit on blur (you don't appear to be in the sample), the onreset event will fire then too.

这篇关于来自 AJAX 回调的 Jeditable CANCEL 回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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