Search code examples
javascriptx-editable

x-editable: callback for cancel evert


For Twitter Bootstrap X Editable (https://vitalets.github.io/x-editable/docs.html), there's a callback for success, and for error. But there's nothing for cancel. Is there a way to listen for the cancel event for a specific editable?


Solution

  • Figured it out:

      $('#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
        }
      });
    

    You can define a listener on "hidden" and check the reason for cancel or submit or manual.