Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flat-json-widget] Preserve newline characters in input fields. Issue where newline characters (\n) in input fields were removed when saving via the HTML form. Updated the logic to ensure newline characters are preserved in both display and saved data. Fixed #19 #32

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var initJsonKeyValueWidget = function(fieldName, inlinePrefix) {
rows.each(function() {
var inputs = $(this).find('input'),
key = inputs.eq(0).val(),
value = inputs.eq(1).val();
value = inputs.eq(1).val() && inputs.eq(1).val().replace(/\\n/g , '\n');
newValue[key] = value;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h2><%= label %></h2>
</div>
<% } %>
<% for(key in data){ %>
<%= _.template(django.jQuery('.flat-json-row-template-inline').eq(0).html())({ 'key': key, 'value': data[key] }) %>
<%= _.template(django.jQuery('.flat-json-row-template-inline').eq(0).html())({ 'key': key, 'value': data[key].replace('\n' , '\\n') }) %>
<% } %>
</div>

Expand Down