Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 6968

Change events not being recogned

$
0
0

@chinenyem wrote:

So I created a file upload funtion in a bootstrap modal. The person uploads a spreadsheet of data. It is sent to the server from the browser and then returns a json to me to displayed in the diagram. The data is uploaded and shown on the diagram. However when I move a node the diagram doesn't recognize it being moved. Any reasons why?

Here is the code for the upload (it works):
function isInArray(filesAccepted, filetype) {

    if ((filesAccepted.indexOf(filetype.toLowerCase())) > -1){
           $('.errorfile').css('opacity', 0);
           $.ajax({
            type: 'POST',
            url: '/incident_response/import_asset_file',
            data: form_data,
            contentType: false,
            cache: false,
            processData: false,
            async: true,
            success: function(data) {
                    console.log('Success!');
                    var data = JSON.parse(data),
                    initial_data = data['data_list'];
                    initial_data.class= "go.GraphLinksModel";
                    myDiagram.model = go.Model.fromJson(initial_data);
                    phx.modal.hide();
                    $.when(save()).then(save());
            }
          });

    } else {
         $('.errorfile').css('opacity', 1);
    }

}

If i don't upload a file to display and just add a node the diagram it recognizes it, so I know my event listener is working at that time. Here is the code for the event listener:

myDiagram.model.addChangedListener(function(e) {

        if (e.change === go.ChangedEvent.Transaction) {

              if (e.propertyName === "CommittingTransaction" || e.modelChange === "SourceChanged"){
                  console.log("changed")
              }
              if (e.isTransactionFinished && e.oldValue !== "Layout"){
                  console.log( e.oldValue)
                  console.log("start");
                  $.when().then(save());
              }
        }
  })

Sorry if this is confusing.

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6968

Trending Articles