How can I create an AUTOSAVE FUNCTION at certain points in the data entry process?
At certain points in the data entry process, I want the system to AUTOSAVE in order to move the arrow (change the stage).
Like
Dear Tim,
Please find the example of autosave function, which is triggered by particular information inserted.
For example when "stage" was filled in or changed, we need to autosave and reload our page. Therefore, we need to firstly react if field changed, we can do that by using JQuery change method:
// if you already have onEntityInitialized function in your replacing schema, please add only change method onEntityInitialized: function() { this.callParent(arguments); this.on(“change:Stage”, this.savePage, this); },
In the change method we call savePage function, which does autosave and reloads the page:
savePage: function() { this.save({ isSilent: true }); this.reloadEntity(); }
You can use the abovementioned example up to your needs.
Regards,
Anastasia
This is really helpful, thank you Anastasia. I'm looking for the ability to call the savePage function when a field is entered for the first time, not just changed, but I don't see some of the typical Javascript event triggers, such as 'input' or 'mouseleave'. Is there an alternative keyword that we can use for this?
Nels Yehnert,
Hi Nels,
There is no such event that triggers when field is modified for the first time, only when field is changed. But you can use page attributes as flags to indicate that some field was change. See example below:
attributes: { "Stage": { "dependencies": [ { "columns": ["Stage"], "methodName": "stageChanged" } ] }, "WasStageChanged": { "value": false } }, methods: { //method will trigger whenever 'Stage' is changed stageChanged: function() { if (!this.get("WasStageChanged")) { //logic } this.set("WasStageChanged", true); } },
Regards,
Dmytro