From 0cbfa239a4b09f37112bd3ab8e4afbdaf5f9987b Mon Sep 17 00:00:00 2001 From: phasefx Date: Sun, 17 Jul 2005 01:20:22 +0000 Subject: [PATCH] Make sure that the last async fired is the one rendered git-svn-id: svn://svn.open-ils.org/ILS/trunk@1236 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../content/evergreen/patron/patron_search.js | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search.js b/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search.js index abeac7ce5e..1146ee5463 100644 --- a/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search.js +++ b/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search.js @@ -73,6 +73,19 @@ function patron_search_patron_search_results_init(p) { } } + var patron_select_async_count = 0; + + function gen_patron_select_async_function(count) { + return function (request) { + /* Set new patron */ + if (count == patron_select_async_count) { + p._patron = request.getResultObject(); + render_fm( p.w.document, { 'au' : p._patron } ); + p.retrieve_button.disabled = false; + }; + } + } + p.search_results.register_patron_select_callback( function (ev) { sdump('D_PATRON_SEARCH','Firing patron_select_callback\n'); @@ -82,15 +95,11 @@ function patron_search_patron_search_results_init(p) { render_fm( p.w.document, { 'au' : p._patron } ); /* Get selection */ var patrons = get_list_from_tree_selection( p.search_results.paged_tree.tree ); + /* Get patron and render status */ retrieve_patron_by_id( patrons[ patrons.length - 1 ].getAttribute('record_id'), - function (request) { - /* Set new patron */ - p._patron = request.getResultObject(); - render_fm( p.w.document, { 'au' : p._patron } ); - p.retrieve_button.disabled = false; - } - ) + gen_patron_select_async_function( ++patron_select_async_count ) + ); } ); p.search_results.register_flesh_patron_function( -- 2.11.0