Bugzilla – Attachment 146601 Details for
Bug 32933
Use val() instead of attr("value") when getting field values with jQuery
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32933: Use val() instead of attr("value") when getting field values with jQuery
Bug-32933-Use-val-instead-of-attrvalue-when-gettin.patch (text/plain), 12.10 KB, created by
Alex Buckley
on 2023-02-13 20:56:39 UTC
(
hide
)
Description:
Bug 32933: Use val() instead of attr("value") when getting field values with jQuery
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2023-02-13 20:56:39 UTC
Size:
12.10 KB
patch
obsolete
>From db4bcd014eb1841fd663dc365bf303763860ce78 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 9 Feb 2023 16:50:38 +0000 >Subject: [PATCH] Bug 32933: Use val() instead of attr("value") when getting > field values with jQuery > >This patch replaces instances in Koha's templates where "attr('value')" is >used to get the value of a form field, using "val()" instead. This >ensures that we get the current value of the field, not just the >value of the field when the page first loaded. > >To test, apply the patch and test the following pages: > >- Tools -> Tags. Use the "Check lists" form in the right-hand sidebar > to test the approval status of some approved and rejected tags. It > should correctly respond with the tag's status. >- Cataloging -> Label creator. > - New -> Printer profile. Each offset and creep field should correctly > reflect the selected value in the "Units" dropdown. Changing the > dropdown should make the units change accordingly. > - New -> Label template. Perform the same tests as above. >- Tools -> Patron card creator. > - New -> Layout. If necessary, check the "Field 1" checkbox. The > units should be displayed correctly and change as you change the > "Units" dropdown. > - New -> Printer profile, > - New -> Card template: Perform the same tests as above. >- Lists -> List contents. > - Check that the "Add to" dropdown menu works for adding selected > titles to a cart or another list. >- Back record modification. Submit a batch of records for modification > and go to Administration -> Manage jobs. > - View the details of the job you just submitted. > - Confirm that the "Add modified records to the following list" > dropdown works correctly. >- Cataloging -> Find a bibliographic record -> Edit items. > - Confirm that clicking a cell in the table of existing items > triggers the "Edit item/Delete item" menu, and that these links > work correctly. > >Works as described. > >Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz> >--- > .../background_jobs/batch_biblio_record_modification.inc | 2 +- > .../prog/en/modules/acqui/duplicate_orders.tt | 2 +- > .../prog/en/modules/labels/label-edit-profile.tt | 2 +- > .../prog/en/modules/labels/label-edit-template.tt | 2 +- > .../prog/en/modules/patroncards/edit-layout.tt | 2 +- > .../prog/en/modules/patroncards/edit-profile.tt | 2 +- > .../prog/en/modules/patroncards/edit-template.tt | 2 +- > .../prog/en/modules/virtualshelves/shelves.tt | 8 ++++---- > koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js | 2 +- > koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js | 2 +- > 10 files changed, 13 insertions(+), 13 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_biblio_record_modification.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_biblio_record_modification.inc >index e766e78adf..534c9a9522 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_biblio_record_modification.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_biblio_record_modification.inc >@@ -54,7 +54,7 @@ > $("#add_bibs_to_list").change(function(){ > var selected = $("#add_bibs_to_list").find("option:selected"); > if ( selected.attr("class") == "shelf" ){ >- var shelfnumber = selected.attr("value"); >+ var shelfnumber = selected.val(); > var bibs = new Array(); > [% FOREACH message IN job.messages %] > [% IF message.code == 'biblio_modified' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt >index 953e5dec22..95861eefe6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt >@@ -421,7 +421,7 @@ Acquisitions › Koha > $("#batch_edit_form").on("submit", function(e){ > var budget_value_will_be_reused = $("input[name='copy_existing_value'][value='budget_id']").is(':checked'); > if ( ! budget_value_will_be_reused ) { >- if ($("#all_budget_id").find("option:selected").attr("value") == "" ) { >+ if ($("#all_budget_id").find("option:selected").val() == "" ) { > alert(MSG_NO_FUND_SELECTED); > e.preventDefault(); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-profile.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-profile.tt >index a0a1eace08..f19e46869e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-profile.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-profile.tt >@@ -149,7 +149,7 @@ > <script> > $(document).ready(function(){ > $('#navmenulist a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current"); >- var selectedUnit = $("#units option:selected").attr("value"); >+ var selectedUnit = $("#units option:selected").val(); > var unitfields = $("#offset_horz,#offset_vert,#creep_horz,#creep_vert"); > $(unitfields).after("<span class=\"unit\">"+getUnit(selectedUnit)+"</span>"); > $("#units").change(function(){ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-template.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-template.tt >index 7ee480b29d..c4e7b6d172 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-template.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-template.tt >@@ -194,7 +194,7 @@ > <script> > $(document).ready(function(){ > $('#navmenulist a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current"); >- var selectedUnit = $("#units option:selected").attr("value"); >+ var selectedUnit = $("#units option:selected").val(); > var unitfields = $("#page_height,#page_width,#label_width,#label_height,#top_margin,#left_margin,#top_text_margin,#left_text_margin,#col_gap,#row_gap"); > $(unitfields).after("<span class=\"unit\">"+getUnit(selectedUnit)+"</span>"); > $("#units").change(function(){ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt >index 3f11ae909c..4ccd13e469 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt >@@ -499,7 +499,7 @@ > [% MACRO jsinclude BLOCK %] > <script> > $(document).ready(function() { >- var selectedUnit = $("#units option:selected").attr("value"); >+ var selectedUnit = $("#units option:selected").val(); > var unitfields = $("#font_size,#field_1_llx,#field_1_lly,#field_2_llx,#field_2_lly,#field_3_llx,#field_3_lly,#barcode_Tx,#barcode_Ty,#image_1_Dx,#image_1_Tx,#image_1_Ty,#image_2_Dx,#image_2_Tx,#image_2_Ty"); > $(unitfields).after("<span class=\"unit\">"+getUnit(selectedUnit)+"</span>"); > $("#units").change(function(){ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-profile.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-profile.tt >index 5fe6b3146a..af4e464fd7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-profile.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-profile.tt >@@ -130,7 +130,7 @@ > [% MACRO jsinclude BLOCK %] > <script> > $(document).ready(function(){ >- var selectedUnit = $("#units option:selected").attr("value"); >+ var selectedUnit = $("#units option:selected").val(); > var unitfields = $("#offset_horz,#offset_vert,#creep_horz,#creep_vert"); > $(unitfields).after("<span class=\"unit\">"+getUnit(selectedUnit)+"</span>"); > $("#units").change(function(){ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-template.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-template.tt >index 4c3eda4a04..c4a2105973 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-template.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-template.tt >@@ -185,7 +185,7 @@ > [% Asset.js("js/tools-menu.js") | $raw %] > <script> > $(document).ready(function(){ >- var selectedUnit = $("#units option:selected").attr("value"); >+ var selectedUnit = $("#units option:selected").val(); > var unitfields = $("#page_height,#page_width,#card_width,#card_height,#top_margin,#left_margin,#col_gap,#row_gap"); > $(unitfields).after("<span class=\"unit\">"+getUnit(selectedUnit)+"</span>"); > $("#units").change(function(){ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >index 605a074f5e..12a4b826d2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >@@ -882,24 +882,24 @@ > function cartList(){ > var checkboxes = $("#searchresults").find(":checkbox"); > var vshelf = vShelfAdd(checkboxes); >- if($("#addto").find("option:selected").attr("value") == "addtolist"){ >+ if($("#addto").find("option:selected").val() == "addtolist"){ > var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s",""); > if (vshelf) { > openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&' + vshelf,'popup',500,500); > } > return false; >- } else if($("#addto").find("option:selected").attr("value") == "newlist"){ >+ } else if($("#addto").find("option:selected").val() == "newlist"){ > if (vshelf) { > openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?newshelf=1&' + vshelf,'popup',500,500); > } > return false; >- } else if($("#addto").find("option:selected").attr("value") == "morelists"){ >+ } else if($("#addto").find("option:selected").val() == "morelists"){ > if (vshelf) { > openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?' + vshelf,'popup',500,500); > } > return false; > } >- if($("#addto").find("option:selected").attr("value") == "addtocart"){ >+ if($("#addto").find("option:selected").val() == "addtocart"){ > addMultiple(checkboxes); > return false; > } >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >index ba2a40ef5f..65a86a2175 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >@@ -15,7 +15,7 @@ $(document).ready(function(){ > > $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit"); > /* Inline edit/delete links */ >- var biblionumber = $("input[name='biblionumber']").attr("value"); >+ var biblionumber = $("input[name='biblionumber']").val(); > $("tr.editable").each(function(){ > $(this).find("td:not(:first)").on('click', function(){ > var rowid = $(this).parent().attr("id"); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js b/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js >index d291768979..260b44fef0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js >@@ -148,7 +148,7 @@ $(document).ready(function() { > $(event.target).text( __("Testing...") ).prop('disabled', true); > $.ajax(Object.assign({}, review_ajax_params, { > data: { >- test: $('#test').attr("value") >+ test: $('#test').val() > }, > success: success_test_call // success_reject > })); >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32933
:
146444
|
146601
|
146978
|
147605