vitalets / x-editable

In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
http://vitalets.github.io/x-editable
MIT License
6.51k stars 1.73k forks source link

Returning {newValue: null} from validate function does not set the property to null. #1110

Closed MattPress closed 5 years ago

MattPress commented 5 years ago

I'm not sure if this is intended behavior or a valid issue.

I am using x-editable with a select2 input and when the user clears the selection i want to set the value of my property to null. This however does not work and the original value is posted to the server.

this.$el.find('<element selector>').editable({
      type: 'select2',
      source: [...],
      select2: {
        allowClear: true
      },
      validate(value) {
        if (value === '') {
          return {
            newValue: 'new value'
          };
        }
        return false;
      }
    });
MattPress commented 5 years ago

Nothing to do with x-editable. Apologies!