forked from 0x2620/oxjs
update code/example panels ('selected' option)
This commit is contained in:
parent
919f119422
commit
92d4b032da
2 changed files with 57 additions and 41 deletions
|
|
@ -10,6 +10,7 @@ Ox.ExamplePanel = function(options, self) {
|
|||
path: '',
|
||||
replaceCode: [],
|
||||
replaceComment: [],
|
||||
selected: '',
|
||||
size: 256
|
||||
})
|
||||
.options(options || {})
|
||||
|
|
@ -49,17 +50,18 @@ Ox.ExamplePanel = function(options, self) {
|
|||
}
|
||||
],
|
||||
items: self.items,
|
||||
selected: [self.options.selected],
|
||||
max: 1,
|
||||
selected: self.options.selected
|
||||
? [self.options.selected] : [],
|
||||
scrollbarVisible: true,
|
||||
sort: ['+title']
|
||||
})
|
||||
.bindEvent({
|
||||
select: function(data) {
|
||||
selectExample(data.ids[0] || '');
|
||||
selectItem(data.ids[0] || '');
|
||||
}
|
||||
});
|
||||
self.$panel.replaceElement(0, self.$list);
|
||||
selectExample(self.options.selected);
|
||||
that.triggerEvent('load', {});
|
||||
});
|
||||
|
||||
|
|
@ -88,7 +90,7 @@ Ox.ExamplePanel = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
function selectExample(id) {
|
||||
function selectItem(id) {
|
||||
var item;
|
||||
if (id) {
|
||||
item = Ox.getObjectById(self.items, id);
|
||||
|
|
@ -111,6 +113,13 @@ Ox.ExamplePanel = function(options, self) {
|
|||
that.triggerEvent('select', {id: id});
|
||||
}
|
||||
|
||||
self.setOption = function(key, value) {
|
||||
if (key == 'selected') {
|
||||
Ox.print('SETTING LIST SELECTED TO', [value])
|
||||
self.$list.options({selected: [value]});
|
||||
}
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue