Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
<script src="raphael.savage.js" ></script>
<script type="text/javascript">
$(function() {
// Connect the div to a Savage.Editor instance.
var savageEditor = new Savage.Editor("savage-editor");
// When the get json button is clicked:
$("#savage-editor-get-json").on("click", function(){
var jsonRepresentation = savageEditor.saveToJSON();
// jsonRepresentation will now contain the full svg data of the editor. You could store this in a database.
$("#savage-editor-load-json").on("click", function(){
// you can retreive the json description from your database, or write something manually:
var jsonRepresentation = '{"objects":[{"type":"arrow","start":{"x":129,"y":196},"stop":{"x":264,"y":195},"color":"#ee0000"}]}';
// clear the editor if you want
// load the json into the editor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment