myDiagram.isModified

    myDiagram.isModified = false;
    console.log(myDiagram.isModified);

Everytime returns true, why is that?

I’m using 1.3.8

When are you trying to set it to false?

As long as a transaction is ongoing or an undo has been done, .isModified will be true. When the transaction is completed or it is fully redone, .isModified will automatically become false.

I dragged a few objects onto my diagram, save it. In my save function, I set isModified to false.

However it keeps displaying true. What constitutes to a transaction?

This is my “Save” function code

function saveDocument() {

    if ($("#currentFileName").text() == newFileName) {
        saveAsDocument();
    } else {
        $.when(asyncSaveAsFloorplan()).done(
            function (status) {
                if (status == true) {
                    displayAlert("#alerts-placeholder", "Append", "success", "Saved successfully.", true, true, false, 1, "fa-check");

                } else {
                    displayAlert("#alerts-placeholder", "Append", "danger", "Saved successfully.", true, true, false, 0, "fa-warning");
                }
            }
        );
    }            
}


function asyncSaveAsFloorplan() {
    var result = new jQuery.Deferred();
    var str = myDiagram.model.toJson();

    $("#floorplan-coordinates").val(str);
    $.ajax({
        type: "POST",
        url: $("#designer-url").val(),
        dataType: "json",
        data: $("#floorplan-designer-form").serialize(),
        success: function (data) {
            if (data.HasErrors == true) {
                $("#floorplan-error-message").text(data.ErrorMessage);
                $('.alert-danger', $('#floorplan-form')).show();
                result.resolve(false);
            } else {
                $("#currentFileName").text(data.FloorPlan.Name);
                $("#floorplan-id").val(data.FloorPlan.Id);
                result.resolve(true);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.error(XMLHttpRequest.responseText + ' ' + textStatus + ' ' + errorThrown);
            $("#floorplan-error-message").text("A javascript error occured.");
            $('.alert-danger', $('#floorplan-form')).show();
            result.resolve(false);
        }
    });
    
    myDiagram.undoManager.isEnabled = true;
    myDiagram.isModified = false;        
    return result.promise();
}

At the time that you set Diagram.isModified, what are the values of the following expressions?
myDiagram.undoManager.isInTransaction
myDiagram.undoManager.isUndoingRedoing
myDiagram.undoManager.currentTransaction
myDiagram.undoManager.transactionLevel

my currentTransaction has this:

ge {<span =“name” style="-sizing: border-; color: rgb136, 19, 145; font-family: Consolas, ‘Lucida Console’, monospace; font-style: italic; line-height: 13px; : rgb255, 255, 255;">aG: <span =“console-atted-” style="-sizing: border-; : relative; display: inline-block; vertical-align: top; color: rgb34, 34, 34; font-family: Consolas, ‘Lucida Console’, monospace; font-style: italic; line-height: 13px; : rgb255, 255, 255;">A, <span =“name” style="-sizing: border-; color: rgb136, 19, 145; font-family: Consolas, ‘Lucida Console’, monospace; font-style: italic; line-height: 13px; : rgb255, 255, 255;">Mb: <span =“console-atted-” style="-sizing: border-; color: rgb196, 26, 22; white-space: pre; unicode-bidi: -webkit-isolate; font-family: Consolas, ‘Lucida Console’, monospace; font-style: italic; line-height: 13px; : rgb255, 255, 255;">"", <span =“name” style="-sizing: border-; color: rgb136, 19, 145; font-family: Consolas, ‘Lucida Console’, monospace; font-style: italic; line-height: 13px; : rgb255, 255, 255;">HB: <span =“console-atted-boolean” style="-sizing: border-; color: rgb28, 0, 207; font-family: Consolas, ‘Lucida Console’, monospace; font-style: italic; line-height: 13px; : rgb255, 255, 255;">false, <span =“name” style="-sizing: border-; color: rgb136, 19, 145; font-family: Consolas, ‘Lucida Console’, monospace; font-style: italic; line-height: 13px; : rgb255, 255, 255;">toString: <span =“console-atted-” style="-sizing: border-; color: rgb34, 34, 34; font-family: Consolas, ‘Lucida Console’, monospace; font-style: italic; line-height: 13px; : rgb255, 255, 255;">function, <span =“name” style="-sizing: border-; color: rgb136, 19, 145; font-family: Consolas, ‘Lucida Console’, monospace; font-style: italic; line-height: 13px; : rgb255, 255, 255;">clear: <span =“console-atted-” style="-sizing: border-; color: rgb34, 34, 34; font-family: Consolas, ‘Lucida Console’, monospace; font-style: italic; line-height: 13px; : rgb255, 255, 255;">function…}




How can I clear this?

First, having UndoManager.currentTransaction non-null means that something has changed.
Second, I would call toString() on that object, just so it’s more human readable. You can pass a positive number as an argument, to show more details with larger values. That will give you more information about what changed and hopefully give you a clue about why.