从AJAX回调Jeditable CANCEL回调? [英] Jeditable CANCEL callback from AJAX callback?

查看:275
本文介绍了从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.

感谢您的回覆,

Carlos

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天全站免登陆