Skip to content

Commit

Permalink
json editor move event where child editors can subscribe (json-editor…
Browse files Browse the repository at this point in the history
…#315)

* json editor move event where child editors can subscribe

* updated move event test
  • Loading branch information
German Bisurgi authored and marc7000 committed Mar 1, 2019
1 parent b18f3be commit c808236
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/editors/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,14 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
self.refreshTabs();

self.onChange(true);

self.jsoneditor.trigger('move');

// TODO we can remove this eventually
self.rows.forEach(function (row) {
row.onMove();
});

});

if(controls_holder) {
Expand All @@ -623,6 +628,10 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
self.active_tab = self.rows[i+1].tab;
self.refreshTabs();
self.onChange(true);

self.jsoneditor.trigger('move');

// TODO we can remove this eventually
self.rows.forEach(function (row) {
row.onMove();
});
Expand Down
4 changes: 2 additions & 2 deletions tests/pages/array-move-events.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

editor.setValue(["A","B"]);

editor.getEditor('root.0').onMove = function () {
editor.on('move', function () {
alert('item array moved')
console.log('moved')
}
});


</script>
Expand Down

0 comments on commit c808236

Please sign in to comment.