I'd like to make a JS API call in the EasyEditSaveComplete event's callback function so that, after the user has saved changes on the Metadata screen, a particular metadata field is then updated on the fly (I'm developing a plugin to handle Metadata Thesaurus Fields and am updating the field with a string of Thesaurus terms separated by commas):
EasyEditEventManager.bind('EasyEditSaveComplete', function() {
// enhanced JS API setMetadata() call made here
});
However, when the screen refreshes and the user goes on to make another change (and the saving process is repeated), changes to the metadata fields are not saved, i.e. only changes made before the first EasyEditSaveComplete callback are saved.
This only happens when a JS API function is called in EasyEditSaveComplete; running standard code within the callback is fine.
Does anyone have any suggestions as to why this is happening?
There could be a few things here. The event you are binding to occurs after the user clicks the save button and triggers a screen save in the code. The screen save will run the current screens save function AND re-load the screen. If you are trying to tap into things that exist on that screen, like user entered data, that will be gone by the time that event runs.
Also, if you are running API calls you probably want to prevent people from clicking around the interface at the same time until your api call is complete, you could use the EES loading overlay for this:
EasyEditOverlay.showOverlay('loading');
//or
EasyEditOverlay.showOverlay('loading',{message: "My loading message"});
I don't have any supportable suggestions for you to add your own code into the save of a screen. Currently you would have to overload core functions which would most definitely cause upgrade hassles.
Hi Anthony - thanks for that useful information. Can I ask whether there are any plans to introduce the ability to amend Metadata Thesaurus Fields in the EES?
Also, do you have any high-level thoughts on how I might go about doing this and whether there were any issues if attempts were made by you guys to implement such a feature?
We are reviewing the possibility of adding support for this metadata field in the current round of development. I haven't investigated all the issues around supporting it yet so I couldn't say whether it will make it in or not, but we'll have more of an idea in a month or 2. You could potentially be duplicating effort writing your own.