Bug 11877 - Eliminate use of deprecated jQuery .live() method
Summary: Eliminate use of deprecated jQuery .live() method
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-28 19:45 UTC by Owen Leonard
Modified: 2015-06-04 23:30 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 11877 - Eliminate use of deprecated jQuery .live() method (6.13 KB, patch)
2014-02-28 19:57 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 11877 - Eliminate use of deprecated jQuery .live() method (6.13 KB, patch)
2014-03-04 07:46 UTC, Marc Véron
Details | Diff | Splinter Review
[Signed-off] Bug 11877 - Eliminate use of deprecated jQuery .live() method (6.34 KB, patch)
2014-03-04 07:53 UTC, Marc Véron
Details | Diff | Splinter Review
[PASSED QA] Bug 11877 - Eliminate use of deprecated jQuery .live() method (6.68 KB, patch)
2014-03-16 14:08 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2014-02-28 19:45:13 UTC
JavaScript in a few templates uses the now-deprecated .live() method. This should be replaced with .on() in preparation for an upgrade of jQuery.
Comment 1 Owen Leonard 2014-02-28 19:57:43 UTC Comment hidden (obsolete)
Comment 2 Owen Leonard 2014-02-28 20:11:44 UTC
FYI, I'll be referring to this page for further updates: http://jquery.com/upgrade-guide/1.9/
Comment 3 Jonathan Druart 2014-03-03 15:40:25 UTC
Comment on attachment 25744 [details] [review]
Bug 11877 - Eliminate use of deprecated jQuery .live() method

Review of attachment 25744 [details] [review]:
-----------------------------------------------------------------

::: koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
@@ +40,4 @@
>              }
>              return valid;
>          });
> +        $("body").on("click","#renewselected_link",function(){

IS there a reason to prefer this way instead of:
  $("#renewselected_link").on("click", function(){
?
Comment 4 Owen Leonard 2014-03-03 17:57:10 UTC
> IS there a reason to prefer this way instead of:
>   $("#renewselected_link").on("click", function(){

".click(function(){" is an shortcut for ".on("click",function(){", so most of the time the two are completely interchangeable.

In this case we need to use ".on()" because we're attaching an event to an element which has not yet been created. The use of ".on()" quoted above means, "For all existing and future instances of '#renewselected_link' which are descendents of "body," attach this click handler."

http://api.jquery.com/on/
Comment 5 Marc Véron 2014-03-04 07:20:09 UTC
I found a problem with step 2:

How to repruduce:

Click on "Change password"

It displays the form "Change unsername and/or password for e.g. Edna Acosta

Field "New username" is filled with usernumber (?): 23529001000463 (Would expect the user name here, not the number - but I think this is not related to this bug?)

Then I click on "Click to fill with randoly generated password" 

Password fields are filled with new value, e.g. 'xcJ' (OK)

Then I clear the password fields and click again for password suggestion

Result: Password fields stay empty. (Would expect new suggstion.)

Console says: "Kein Element gefunden (No element found)"
file:///C:/Users/ApDAta/Roaming/Mozilla/Firefox/o1dv3kga.default/clipdat2.rdf

I tested with Chrome as well, same behaviour.
Comment 6 Marc Véron 2014-03-04 07:45:48 UTC
Problem with step 2 exists without patch as well.

Will sign off on this patch and file an other bug for step 2
Comment 7 Marc Véron 2014-03-04 07:46:54 UTC Comment hidden (obsolete)
Comment 8 Marc Véron 2014-03-04 07:53:25 UTC Comment hidden (obsolete)
Comment 9 Katrin Fischer 2014-03-16 14:08:20 UTC
Created attachment 26377 [details] [review]
[PASSED QA] Bug 11877 - Eliminate use of deprecated jQuery .live() method

As of jQuery 1.9 the .live() method has been removed. A few templates
contain JavaScript which uses it. It can be easily replaced with .on().
This patch makes the correction.

To test, apply the patch and test the following pages:

- In the staff client, Administration -> OAI sets configuration:
  Define mappings for an existing set. You should be able to add rows by
  clicking the "OR" button. You should be able to delete or clear any
  line by clicking the "Delete" link.

- In the staff client, view the details for any patron and click the
  "Change password" button: In the change password form click the link
  to fill the password fields with a random password. This link should
  work correctly.

- If necessary enable OpacRenewalAllowed in system preferences. Log in
  to the OPAC as a patron who has checkouts. On the patron summary page
  (opac-user.pl) look for the "renew selected" and "renew all" links at
  the top of the table of checkouts. Both these links should work
  correctly. Test in prog and bootstrap themes.

Followed test plan. Same behaviour as without patch, i.e. patch OK
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script, works as described.
No Javasript errors found.

Note: The buttons on the form show up, even if no item shows the
checkbox. In my case the problem was that I had 0 renewals allowed
in the circulation rules. Maybe we could hide them, if no item
can be renewed.
Comment 10 Galen Charlton 2014-03-26 19:20:05 UTC
Pushed to master.  Thanks, Owen!
Comment 11 Fridolin Somers 2014-06-12 10:06:25 UTC
Pushed to 3.14.x, will be in 3.14.08
Comment 12 Kyle M Hall (khall) 2014-06-13 13:22:39 UTC
Pushed to 3.12.x, will be in 3.12.13