diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-04-13 23:39:49 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-04-15 19:46:22 -0400 |
| commit | 78532e8efec1b39d8f7b9286508cc10e5050fe69 (patch) | |
| tree | e951f12d55d8b89ca9d30a84249e9be725c09919 /print/resources | |
| parent | 85a8b6b1cfe008eed49c678bc0af9e2bea931f3c (diff) | |
populate fields on load
Diffstat (limited to 'print/resources')
| -rw-r--r-- | print/resources/inkstitch.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index ed26d367..15cf494a 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -48,10 +48,17 @@ $(function() { $('[contenteditable="true"]').on('focusout', function() { var content = $(this).html(); var field_name = $(this).attr('data-field-name'); - $('[data-field-name="' + field_name + '"]').html(content); + $('[data-field-name="' + field_name + '"]').text(content); $.post('/metadata/' + field_name + '/set', {value: content}); }); + // load up initial metadata values + $.getJSON('/metadata', function(metadata) { + $.each(metadata, function(field_name, value) { + $('[data-field-name="' + field_name + '"]').text(value); + }); + }); + $('[contenteditable="true"]').keypress(function(e) { if (e.which == 13) { // pressing enter defocuses the element |
