JS - Determine that an entry is unsaved? I've created a custom fieldtype... which is basically a button that triggers an AJAX action. When I add this field to my section, I can click the button while I'm editing an entry to perform an action.

Here's the thing... How can I tell if the entry needs to be saved? Clearly Craft is aware of whether an entry is unsaved or not, because it'll warn you before navigating away from the page. Is it possible for my button to tap into that same behavior?

MORE INFO:

This button does not take people away from the page, so I'm not sure if data-confirm-unload really comes into play here. If the entry is unsaved, the button will be replaced with a message saying, "you must first save the entry".
Craft checks if a form has changed using javascript in the cp.js file, see line 196.

You could replicate this quite easily yourself though, here is a stripped down example:

var initialFormValues = $('form[data-confirm-unload]').serialize();

function checkFormChanged() {
    if ($('form[data-confirm-unload]').serialize() != initialFormValues) {
        return true;
    }

    return false;
}