From 78532e8efec1b39d8f7b9286508cc10e5050fe69 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 13 Apr 2018 23:39:49 -0400 Subject: [PATCH] populate fields on load --- print/resources/inkstitch.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index ed26d3671..15cf494ac 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