mosaico
mosaico copied to clipboard
Detecting unsaved changes
Is there a method to determine if there are unsaved changes?
Writing some Javascript to alert the user upon navigation.
Solutions:
A) saved state
- change the save code so to store in memory the "latest saved json".
- upon navigation run an "viewModel.exportJSON()" and compare it to the "last saved json".
B) dirty flag
- add a "dirty" boolean to the viewModel
- made dirty = false when you save
- make dirty = true when you make any change (maybe in a plugin working like the "undomanager plugin".
- upon navigation check the dirty flag.
Both could be made generic enough to be included in the main baseline... I don't plan to have time soon... maybe I can work on something similar in the next months. Contributions are welcome.