Currntly working on the tournament bracket,
trying to make a bracket that saves the scores being entered. main issue is im trying to ccreate a submit button within my tournament script, tried a few things looked around gojs documentation and wandered around the forum didnt find much anybody that faced this issue that as any tips thanks :)
Many of the samples have a “Save” HTML button that saves the result of calling myDiagram.model.toJson()
.
Or you could automatically save at the end of each transaction, as many of the samples do by implementing a “ModelChanged” DiagramEvent listener that does:
$(go.Diagram, . . ., {
. . .,
"ModelChanged": function(e) { if (e.isTransactionFinished) saveModel(); }
})
where saveModel
also calls Model.toJson.
Please read more at GoJS Using Models -- Northwoods Software
:/ none of it works, added the saving of my model toJson, and tried also the modelchanged to script, none of it worked my script wasnt even showing :/.
is it possible to write a button that does it onclick
Yes, it is possible, as so many of the samples demonstrate.
Could you please be more specific about what is not working? How is what you have tried different from the samples that have “Save” and “Load” HTML buttons?
tried with this line (which is part of my script)
right after the end of my init
i added var userbracket = model.toJson();
Yes, so you got the model as a string in JSON format. OK, so what else have you done and what else are you trying to do?
im sorry im not very good at script, learning as i go along,
is to have my edited bracket (edited by a user) saved into a json, and have that edited bracket display into another html page. each user edited bracket is associated to a user via user_id
OK, so now you can see the data in the JSON-formatted text. Later when you call JSON.parse on this string you will have an Object whose nodeDataArray
property is an Array of nodes. In each of those node data objects you can see who player1
and player2
are along with their respective scores.