Skip to content

Commit

Permalink
Support readonly fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Kampert committed Aug 19, 2014
1 parent fa9edb2 commit 1a8cb57
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion examples/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,22 @@ <h1>JSON Editor Upload Example</h1>
type: "object",
title: "Image",
properties: {
uri: {
upload1: {
type: "string",
format: "uri",
options: {
upload: true
}
},
upload2: {
type: "string",
format: "uri",
options: {
upload: true
}
},
readonly: {
readonly: true,
type: "string",
format: "uri",
options: {
Expand All @@ -56,6 +71,13 @@ <h1>JSON Editor Upload Example</h1>
}
}
});

editor.setValue({
upload1: "",
upload2: "",
readonly: "http://www.example.com/images/image.jpg",
name: ""
});

// Hook up the submit button to log to the console
document.getElementById('submit').addEventListener('click',function() {
Expand Down
2 changes: 1 addition & 1 deletion src/editors/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ JSONEditor.defaults.editors.upload = JSONEditor.AbstractEditor.extend({
downloadLink.appendChild(anchor);

this.downloadLink = downloadLink;
this.control.insertBefore(this.downloadLink, this.uploader);
this.label.parentNode.insertBefore(this.downloadLink, this.label.nextSibling);
},
enable: function() {
if(this.uploader) this.uploader.disabled = false;
Expand Down

0 comments on commit 1a8cb57

Please sign in to comment.