json-forms icon indicating copy to clipboard operation
json-forms copied to clipboard

CleanData after onChange between oneOf

Open chrisdr84 opened this issue 6 years ago • 4 comments

When you select one of the list from the oneOf and move to un-select, the value is still saved in the container.

For example, select [An object] from the oneOf example and than select []. When you getData(), the values are still stored in the container.

This kind of situation will mismatch the two function validate() and getData() For example select [A multiple of 3] and fill with number 10. The getData() will get the value 10 and the validate() will show error.

However, when you select [] and repeat the two function, getData() will get the value 10 and validata() will show success.

http://brutusin.org/json-forms/#7

chrisdr84 avatar Jun 12 '18 06:06 chrisdr84

This should solve the problem,

input.onchange = function () { cleanData(id); render(null, display, id + "." + (input.selectedIndex - 1), parentObject, propertyProvider, value);
};

chrisdr84 avatar Jun 12 '18 06:06 chrisdr84

// Get all elements with the 'collapsible' class var collapsibleButtons = document.getElementsByClassName('collapsible');

// Loop through each collapsible element for (var i = 0; i < collapsibleButtons.length; i++) { // Add a click event listener to toggle the 'active' class on click collapsibleButtons[i].addEventListener('click', function() { this.classList.toggle('active');

// Get the sibling element with the 'content' class
var content = this.nextElementSibling;

// Toggle the 'show' class on the content element
if (content.style.display === 'block') {
  content.style.display = 'none';
} else {
  content.style.display = 'block';
}

}); }

peeyush12345 avatar Jun 26 '23 19:06 peeyush12345

// Get all elements with the 'collapsible' class var collapsibleButtons = document.getElementsByClassName('collapsible');

// Loop through each collapsible element for (var i = 0; i < collapsibleButtons.length; i++) { // Add a click event listener to toggle the 'active' class on click collapsibleButtons[i].addEventListener('click', function() { this.classList.toggle('active');

// Get the sibling element with the 'content' class
var content = this.nextElementSibling;

// Toggle the 'show' class on the content element
if (content.style.display === 'block') {
  content.style.display = 'none';
} else {
  content.style.display = 'block';
}

}); }

peeyush12345 avatar Jun 26 '23 19:06 peeyush12345

// Get all elements with the 'collapsible' class var collapsibleButtons = document.getElementsByClassName('collapsible');

// Loop through each collapsible element for (var i = 0; i < collapsibleButtons.length; i++) { // Add a click event listener to toggle the 'active' class on click collapsibleButtons[i].addEventListener('click', function() { this.classList.toggle('active');

// Get the sibling element with the 'content' class
var content = this.nextElementSibling;

// Toggle the 'show' class on the content element
if (content.style.display === 'block') {
  content.style.display = 'none';
} else {
  content.style.display = 'block';
}

}); }

peeyush12345 avatar Jun 26 '23 20:06 peeyush12345