diff --git a/samples/helloworld2.html b/samples/helloworld2.html new file mode 100644 index 0000000..966d988 --- /dev/null +++ b/samples/helloworld2.html @@ -0,0 +1,156 @@ + + + + + JSON Editor + + + + + + +
+ +
+ +

+
+ + + + + + + + diff --git a/src/onde.js b/src/onde.js index 89da995..49b9a2d 100644 --- a/src/onde.js +++ b/src/onde.js @@ -104,18 +104,22 @@ onde.Onde = function (formElement, schema, documentInst, opts) { this.panelElement.find('.field-delete').live('click', function (evt) { evt.preventDefault(); evt.stopPropagation(); //CHECK: Only if collapsible - $('#' + $(this).attr('data-id')).fadeOut('fast', function () { - // Change the item's and siblings' classes accordingly - //FIXME: This is unstable - if ($(this).hasClass('first')) { - $(this).next('li.field').addClass('first'); - } - if ($(this).hasClass('last')) { - $(this).prev('li.field').addClass('last'); - } - $(this).remove(); - }); + + if (confirm("Are you sure you want to delete?")) { + $('#' + $(this).attr('data-id')).fadeOut('fast', function () { + // Change the item's and siblings' classes accordingly + //FIXME: This is unstable + if ($(this).hasClass('first')) { + $(this).next('li.field').addClass('first'); + } + if ($(this).hasClass('last')) { + $(this).prev('li.field').addClass('last'); + } + $(this).remove(); + }); + } }); + // Type selector this.panelElement.find('.field-type-select').live('change', function (evt) { evt.preventDefault(); @@ -159,6 +163,14 @@ onde.Onde.prototype.renderObject = function (schema, parentNode, namespace, data sortedKeys.push(propName); } } + // Check for additional properties + if(schema.additionalProperties) { + for (var propName in data) { + sortedKeys.push(propName); + props[propName] = schema.additionalProperties; + props[propName]._deletable = true; + } + } // Last property to be collected is the primary, if any. if (schema.primaryProperty) { sortedKeys.unshift(schema.primaryProperty);