From: Bill Erickson Date: Fri, 2 Sep 2011 14:48:46 +0000 (-0400) Subject: TPac: Submit search on sort/limit change X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b29977336a9fcf1eeb0d0c9680e0803a77a5f4dd;p=evergreen%2Fequinox.git TPac: Submit search on sort/limit change By popular demand, when the user changes the search sort or limit-to-available options, the form is immediately resubmitted via JavaScript. Fails gracefully in the absence of JS. Minor JS cleanup. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/web/js/ui/default/opac/simple.js b/Open-ILS/web/js/ui/default/opac/simple.js index c120e4b2f3..6e3d29fc2c 100644 --- a/Open-ILS/web/js/ui/default/opac/simple.js +++ b/Open-ILS/web/js/ui/default/opac/simple.js @@ -46,7 +46,7 @@ function killRowIfAtLeast(min, link) { } function print_node(node_id) { var iframe = document.createElement("iframe"); - var source_node = document.getElementById(node_id); + var source_node = $(node_id); source_node.parentNode.appendChild(iframe); var iwin = iframe.contentWindow; @@ -73,9 +73,14 @@ function select_all_checkboxes(name, checked) { } } } -function avail_change_adv_search(checkbox) { + +function limit_to_avail_onchange(checkbox, submitOnChange) { if (checkbox.form._adv && !checkbox.checked) { - var search_box = document.getElementById("search_box"); + var search_box = $('search_box'); search_box.value = search_box.value.replace(/#available ?/g, ""); } + + if (submitOnChange) { + checkbox.form.submit(); + } } diff --git a/Open-ILS/web/templates/default/opac/parts/filtersort.tt2 b/Open-ILS/web/templates/default/opac/parts/filtersort.tt2 index 428626ce99..664be17fc3 100644 --- a/Open-ILS/web/templates/default/opac/parts/filtersort.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/filtersort.tt2 @@ -1,4 +1,5 @@ - diff --git a/Open-ILS/web/templates/default/opac/results.tt2 b/Open-ILS/web/templates/default/opac/results.tt2 index bfe96330f7..ca343bccfc 100644 --- a/Open-ILS/web/templates/default/opac/results.tt2 +++ b/Open-ILS/web/templates/default/opac/results.tt2 @@ -46,7 +46,7 @@ [% END %]
[% l('Sort by') %]
- [% INCLUDE "default/opac/parts/filtersort.tt2" value=CGI.param('sort') %] + [% INCLUDE "default/opac/parts/filtersort.tt2" value=CGI.param('sort') submit_on_change=1 %]