NicolasCARPi / jquery_jeditable

jQuery edit in place plugin. Extendable via plugin architecture. Plugins for plugin. Really.
https://jeditable.elabftw.net
MIT License
1.74k stars 458 forks source link

How to manage callback results? #213

Closed ottopic closed 4 years ago

ottopic commented 4 years ago

Hello, I have tried to manage server side's result to show to user alert popup if error occurred. Problem is that my callback json result is replaced into edited text field.

Is there a workaround to do this?

Best regards

NicolasCARPi commented 4 years ago

Hello,

Did you look at the complete example from https://jeditable.elabftw.net/ ? There is a callback example:

2020-02-04-131411_459x120_scrot

ottopic commented 4 years ago

Yes sure, but variable result is put by default inside edited text field value. So, if I return form server side script a json like {success: false, error: 'wrong data'} I can't prevent it replace original edited text.

NicolasCARPi commented 4 years ago

Then you might want to use the intercept. There is code for it on the demo page a bit lower.

ottopic commented 4 years ago

Yes, it is. Thank you. Intercept is not mentioned inside documentation and API sections.

Best regards

NicolasCARPi commented 4 years ago

Intercept is not mentioned inside documentation and API sections

Correct! I'll add it.