There should already be an onSave event that you can use for this.