Topic: Problem with isDirty() and onbeforeunload?

I love TinyMCE, but I have some troubles using the isDirty() function. I am using IE11 and tinyMCE 4.4.1.

First it seems that in window.onbeforeunload the value returned by isDirty() is not always reliable.
If I close IE, use the previous button or click a <a>-link it works perfect.
But if I "soft-"submit a form using jQuery then isDirty() always returns false in window.onbeforeunload. My workaround is to use a global variable in javascript. In all the functions that submit the form or may cause some kind of navigation I check isDirty() and if true then I set this global var to true as well. I also set it to true in the tinymce dirty event. In the window.onbeforeunload I check both isDirty() and this global variable, and if either is true I return a message to prompt my users to save their work before leaving the page. This is a bit more complicated than just relying on isDirty() asis, but it seems to trap most situations and works rather well.

This leads me to a second question, because when the onbeforeunload event is fired and the users elects to stay on the page then isDirty() seems to reset to false. In other words, isDirty is true, user gets stay-or-leave prompt and selects "stay": isDirty is false...?
If there would be an option to check whether the user clicked stay-or-leave I could construct a workaround to trap this, but I am not aware of such an event. Even so, I doubt that isDirty() is meant to be used that way. I thought it would be easier smile.

I am not a real js/jquery code pro so I just wonder if this is a known issue (or issues), or did I make wrong assumptions about using isDirty()?

Thanks for your replies!