x-editable:取消事件的回调

x-editable: callback for cancel evert

对于 Twitter Bootstrap X Editable (https://vitalets.github.io/x-editable/docs.html),有成功和错误的回调。但是没有什么可以取消的。有没有办法监听特定可编辑的取消事件?

想通了:

  $('#element', this.$e).editable({
    type: 'text',
    toggle: 'manual',
    success: function(response, newValue) {
      //some action
    }.bind(this)
  }).on('hidden', function(e, reason) {
    if (reason == "cancel") {
      //some action
    }
  });

您可以在 "hidden" 上定义一个侦听器并检查取消或提交或手动的原因。