ExamplePanel: don't fail when selecting non-existing id

This commit is contained in:
rolux 2012-06-20 11:03:37 +02:00
parent 542be904ea
commit a3f0a38bf2

View file

@ -108,9 +108,9 @@ Ox.ExamplePanel = function(options, self) {
}
function selectItem(id) {
var item;
if (id) {
item = Ox.getObjectById(self.items, id);
var item = id ? Ox.getObjectById(self.items, id) : null
if (item) {
self.options.selected = id;
self.$panel.replaceElement(1,
self.$page = Ox.ExamplePage({
height: window.innerHeight,
@ -129,11 +129,11 @@ Ox.ExamplePanel = function(options, self) {
})
);
} else {
self.options.selected = '';
self.$list.options({selected: []});
self.$page.empty().append(self.options.element);
}
self.options.selected = id;
that.triggerEvent('select', {id: id});
that.triggerEvent('select', {id: self.options.selected});
}
return that;