Bugzilla – Attachment 147605 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: [22.05.x] Use val() instead of attr("value") when getting field values with jQuery
Bug-32933-2205x-Use-val-instead-of-attrvalue-when-.patch (text/plain), 12.03 KB, created by
Owen Leonard
on 2023-03-02 12:30:12 UTC
(
hide
)
Description:
Bug 32933: [22.05.x] Use val() instead of attr("value") when getting field values with jQuery
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2023-03-02 12:30:12 UTC
Size:
12.03 KB
patch
obsolete
>From 7362bd0768c89ab35a0513373dc64c94603e5205 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: [22.05.x] 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> >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > .../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 8bb5e07d85..c8e1669f61 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 >@@ -397,7 +397,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 48073db2f9..97fad09cd0 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 >@@ -146,7 +146,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 = $("#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 b3c06474f4..6d4a70678d 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 >@@ -191,7 +191,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,#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 f8e1c2f536..dae9f935ba 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 >@@ -496,7 +496,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 740cc3d1fa..f794af351d 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 >@@ -127,7 +127,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 c9bdbf73b5..8528d52821 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 >@@ -182,7 +182,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 98a0c03cda..e34cc1cedd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >@@ -774,24 +774,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 47f69fe781..864857e5f9 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 fb790551bd..0ec2856c8b 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({ > data: { >- test: $('#test').attr("value") >+ test: $('#test').val() > }, > success: success_test_call // success_reject > }); >-- >2.30.2
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