improve reselection list updates.
This commit is contained in:
parent
e3324d2216
commit
6777957ff2
|
@ -4223,7 +4223,7 @@ List.prototype.removeItem = function(child) {
|
|||
List.prototype.setItems = function(items) {
|
||||
var i = 0
|
||||
, original = this.items.slice()
|
||||
//, selected = this.selected
|
||||
, selected = this.selected
|
||||
, sel = this.ritems[this.selected];
|
||||
|
||||
this.select(0);
|
||||
|
@ -4244,8 +4244,13 @@ List.prototype.setItems = function(items) {
|
|||
|
||||
// Try to find our old item if it still exists.
|
||||
sel = items.indexOf(sel);
|
||||
if (~sel) this.select(sel);
|
||||
//this.select(~sel ? sel : selected);
|
||||
if (~sel) {
|
||||
this.select(sel);
|
||||
} else if (items.length === original.length) {
|
||||
this.select(selected);
|
||||
} else {
|
||||
this.select(Math.min(selected, items.length - 1));
|
||||
}
|
||||
};
|
||||
|
||||
List.prototype.select = function(index) {
|
||||
|
|
Loading…
Reference in New Issue