From a3f0a38bf2e461bba8d18906f6cf3e78f122d8b4 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 20 Jun 2012 11:03:37 +0200 Subject: [PATCH] ExamplePanel: don't fail when selecting non-existing id --- source/Ox.UI/js/Code/ExamplePanel.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/Ox.UI/js/Code/ExamplePanel.js b/source/Ox.UI/js/Code/ExamplePanel.js index 95867381..6a1022d6 100644 --- a/source/Ox.UI/js/Code/ExamplePanel.js +++ b/source/Ox.UI/js/Code/ExamplePanel.js @@ -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;