How to show alert for users to save the changes before closing the designer

To alert users to save changes before they close the Bold Reports® Report Designer, check hasReportChanges for unsaved changes in the window beforeunload event and show the alert, as in the following code sample.

<script type="text/javascript">

    var isFormSubmit = true;
    $(document).ready(function () {
        $(document.body).bind('submit', $.proxy(winformSubmit, this));
        $(window).bind('beforeunload', $.proxy(beforeWindowUnload, this));
    });

    function winformSubmit(args) {
        isFormSubmit = false;
    }

    function beforeWindowUnload(args) {

        if (isFormSubmit) {
            var designer = $('#designer').data('boldReportDesigner');
            if (designer.hasReportChanges()) {
                return 'Changes you made may not be saved';
            }
        }
        isFormSubmit = true;
    }
</script>

See also