diff --git a/source/UI/js/Form/ArrayEditable.js b/source/UI/js/Form/ArrayEditable.js index 47ca4f99..ea890b1e 100644 --- a/source/UI/js/Form/ArrayEditable.js +++ b/source/UI/js/Form/ArrayEditable.js @@ -117,6 +117,8 @@ Ox.ArrayEditable = function(options, self) { self.selected = getSelectedPosition(); function deleteItem(id) { + // it is possible to delete an (empty-value) item + // by selecting another one id = id || self.options.selected; var position = Ox.getIndexById(self.options.items, id) if (self.options.editable) { @@ -124,8 +126,12 @@ Ox.ArrayEditable = function(options, self) { renderItems(); that.triggerEvent('delete', {id: id}); self.editing = false; - self.selected = -1; - self.options.selected = ''; + if (self.options.selected == id) { + self.selected = -1; + self.options.selected = ''; + } else if (self.options.selected) { + self.selected = Ox.getIndexById(self.options.item, self.options.selected) + } } } @@ -361,8 +367,6 @@ Ox.ArrayEditable = function(options, self) { function submitItem(position, value) { var item = self.options.items[position]; if (value === '') { - // submit may have been triggered by selecting another item, - // so don't delete the selected one deleteItem(item.id); } else { that.triggerEvent(item.value === value ? 'blur' : 'submit', {