fix selection after deleting empty-value annotation by selecting another one
This commit is contained in:
parent
8d7c5dd4d3
commit
7d178278c5
1 changed files with 8 additions and 4 deletions
|
@ -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', {
|
||||
|
|
Loading…
Reference in a new issue