Created
October 7, 2014 19:02
-
-
Save jhubert/66be2e9ed0c4904c3d6a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Sir Trevor</title> | |
| <link rel="stylesheet" type="text/css" href="sir-trevor.css"> | |
| <link rel="stylesheet" type="text/css" href="sir-trevor-icons.css"> | |
| </head> | |
| <body> | |
| <form> | |
| <textarea class="js-st-instance">{ | |
| "data":[ | |
| {"type":"heading","data":{"text":"This is the initial heading"}} | |
| ] | |
| }</textarea> | |
| <input type="submit" value="Save"> | |
| </form> | |
| <button onclick="requestData('/testing')">Load Data</button> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/eventable/1.0.4/eventable.min.js"></script> | |
| <script src="sir-trevor.js"></script> | |
| <script> | |
| SirTrevor.DEBUG = true | |
| new SirTrevor.Editor({ el: $('.js-st-instance') }); | |
| $('form').on('submit', function (ev) { | |
| ev.preventDefault(); | |
| var data = SirTrevor.getInstance().dataStore; | |
| alert(JSON.stringify(data)); | |
| console.log(JSON.stringify(data)); | |
| console.log(data) | |
| }); | |
| function requestData(endpoint) { | |
| console.log('Faking data request to endpoint: ' + endpoint); | |
| var json = { | |
| "data":[ | |
| {"type":"heading","data":{"text":"This is a new heading"}}, | |
| {"type":"text","data":{"text":"This is some text content"}} | |
| ] | |
| }; | |
| setData(json) | |
| } | |
| function setData(json) { | |
| var $el = $('.js-st-instance'), | |
| inst = SirTrevor.getInstance(); | |
| $el.text(JSON.stringify(json)); | |
| return inst.reinitialize({ el: $el }); | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment