|
|
@ -818,11 +818,13 @@ ItemSet.prototype._onUpdate = function(ids) { |
|
|
|
var type = me._getType(itemData); |
|
|
|
|
|
|
|
var constructor = ItemSet.types[type]; |
|
|
|
var selected; |
|
|
|
|
|
|
|
if (item) { |
|
|
|
// update item
|
|
|
|
if (!constructor || !(item instanceof constructor)) { |
|
|
|
// item type has changed, delete the item and recreate it
|
|
|
|
selected = item.selected; // preserve selection of this item
|
|
|
|
me._removeItem(item); |
|
|
|
item = null; |
|
|
|
} |
|
|
@ -837,6 +839,10 @@ ItemSet.prototype._onUpdate = function(ids) { |
|
|
|
item = new constructor(itemData, me.conversion, me.options); |
|
|
|
item.id = id; // TODO: not so nice setting id afterwards
|
|
|
|
me._addItem(item); |
|
|
|
if (selected) { |
|
|
|
this.selection.push(id); |
|
|
|
item.select(); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (type == 'rangeoverflow') { |
|
|
|
// TODO: deprecated since version 2.1.0 (or 3.0.0?). cleanup some day
|
|
|
@ -847,7 +853,7 @@ ItemSet.prototype._onUpdate = function(ids) { |
|
|
|
throw new TypeError('Unknown item type "' + type + '"'); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}.bind(this)); |
|
|
|
|
|
|
|
this._order(); |
|
|
|
this.stackDirty = true; // force re-stacking of all items next redraw
|
|
|
|