From 3b23ef88a23af4ecb2e536736e76d885ad16496a Mon Sep 17 00:00:00 2001 From: jos Date: Sun, 3 Jun 2018 13:45:52 +0200 Subject: [PATCH] Fixed sort modal not working when JSONEditor is created inside a form --- src/js/Node.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/js/Node.js b/src/js/Node.js index e007e9c..fb59dd2 100644 --- a/src/js/Node.js +++ b/src/js/Node.js @@ -3780,6 +3780,7 @@ Node.prototype._showSortModal = function () { }) .afterCreate(function (modal) { var form = modal.modalElem().querySelector('form'); + var ok = modal.modalElem().querySelector('#ok'); var field = modal.modalElem().querySelector('#field'); var direction = modal.modalElem().querySelector('#direction'); @@ -3804,8 +3805,9 @@ Node.prototype._showSortModal = function () { setDirection(event.target.getAttribute('data-value')); }; - form.onsubmit = function (event) { + ok.onclick = function (event) { event.preventDefault(); + event.stopPropagation(); modal.close(); @@ -3819,6 +3821,10 @@ Node.prototype._showSortModal = function () { node.sort(pathArray, direction.value) }; + + if (form) { // form is not available when JSONEditor is created inside a form + form.onsubmit = ok.onclick; + } }) .afterClose(function (modal) { modal.destroy();