bootstrap-editable-rails icon indicating copy to clipboard operation
bootstrap-editable-rails copied to clipboard

No error callback

Open russen opened this issue 11 years ago • 0 comments

This is related to https://github.com/vitalets/x-editable/issues/219

There is no 'error:' callback in x-ediable until version 1.4.4 !

The best you can do is add

$('a.editable-click').editable({
    ajaxOptions: {
      error: function (xhr, status, error) {
        if(xhr.status == 422){
          var msg = 'Error: ';
          errors = $.parseJSON(xhr.responseText);
          $.each(errors, function(k, v) {
            msg += k + ": " + v;
          });
          //Edit the response, to be more awesome.
          xhr.responseText = msg;
        } 
      }
    }
});

This edits the content of the error message before x-editable's error() callback fills it into Bootstrap's error blocks.

There's little to be 'fixed' until this gem is updated to use version 1.4.4, so I thought I'd document this problem with a workaround.

russen avatar May 30 '13 18:05 russen