Hi,
just a suggestion, we already have a mechanism for the message prompt when we leave the page without saving the changes (somewhere in ajax.js) which you are doing here also. It will be great if you can trace the cause back there and if possible try to solve at that place. However, if you have another fix for it, you can submit that too.