From d134429953925acafa510ce7ef15949d5c5b3443 Mon Sep 17 00:00:00 2001 From: pines Date: Thu, 8 Mar 2007 20:11:00 +0000 Subject: [PATCH] delay auto-select and call on_select git-svn-id: svn://svn.open-ils.org/ILS/trunk@7047 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/chrome/content/util/list.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js index f90a95fc8e..dd9c2fe7c9 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -340,7 +340,14 @@ util.list.prototype = { if (typeof params.to_bottom != 'undefined') { treechildren_node.appendChild( treeitem ); if (typeof params.no_auto_select == 'undefined') { - try { obj.node.view.selection.select(Number(obj.node.view.rowCount)-1); } catch(E) { obj.error.sdump('D_ALERT','tree auto select: ' + E + '\n'); } + if (!obj.auto_select_pending) { + obj.auto_select_pending = true; + setTimeout(function() { + try { obj.node.view.selection.select(Number(obj.node.view.rowCount)-1); } catch(E) { obj.error.sdump('D_ALERT','tree auto select: ' + E + '\n'); } + try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_ALERT','tree auto select, on_select: ' + E + '\n'); } + obj.auto_select_pending = false; + }, 1000); + } } } else { if (treechildren_node.firstChild) { @@ -349,7 +356,14 @@ util.list.prototype = { treechildren_node.appendChild( treeitem ); } if (typeof params.no_auto_select == 'undefined') { - try { obj.node.view.selection.select(0); } catch(E) { obj.error.sdump('D_ALERT','tree auto select: ' + E + '\n'); } + if (!obj.auto_select_pending) { + obj.auto_select_pending = true; + setTimeout(function() { + try { obj.node.view.selection.select(0); } catch(E) { obj.error.sdump('D_ALERT','tree auto select: ' + E + '\n'); } + try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_ALERT','tree auto select, on_select: ' + E + '\n'); } + obj.auto_select_pending = false; + }, 1000); + } } } var treerow = document.createElement('treerow'); -- 2.11.0