onChange in Dojo widget not reaching the backend

Vote:
 
I'm trying to adapt a custom image cropper Dojo widget for Optimizely CMS 12. Images can be added to the widget by selecting through a button click and subsequently selecting the image from the assets, or by drag-and-drop.
When the image is added to the widget through drag-and-drop the onChange event reaches the back-end, and the page can be saved.
When adding the image through selection the onChange event is fired but the back-end is not notified. Also, just changing the crop dimensions does fire the onChange event, without reaching the back-end.
This is the code which is called in all scenario's:
_setValue: function (value) {
   this._set('value', value);
   this.onChange(value);
   this._updateDisplayNode(value);
   this.validate();
}
Why would onChange work with drag-and-drop and not in the other cases? Is something more necessary to enable the onChange event to reach the back-end. The value passed is the same in all scenario's.
#331239
Oct 10, 2024 15:06
Vote:
 

The answer from Optimizely Support was that in an editor where there is no real focus you have to set it explicitly with onStartEdit and onStopEdit.

The updated code is:

_setValue: function (value) {
    this.onStartEdit();
    this._set('value', value);
    this.onChange(value);
    this._updateDisplayNode(value);
    this.validate();
    this.onStopEdit();
}, 

This solved the problem!

#331293
Oct 11, 2024 13:55
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.