I'm trying to write a app that watches for changed data, then if a
user clicks on something else, it warns them that they have unsaved
data with a modal dialog.

I'm calling e.preventDefault on the event initially and then trying to
make it so if they select yes, the event will be re-triggered.

It seems like a common enough thing, but I'm just going in circles.
What is the best approach for this?

// sudo code
var changed = false;

$(form).bind("change", function () {
    changed = true;
});

$("a").click(function (e) {
    e.preventDefault();
    if (changed) {
        $(modalContent).modal();
        // bind yes
        if (yes) {
            // trigger event ??
        }
    }
});

Reply via email to