#13509 closed defect (fixed)
jquery error around "unload" function
Reported by: | clemens | Owned by: | clemens |
---|---|---|---|
Priority: | normal | Component: | DataSaverPlugin |
Severity: | blocker | Keywords: | |
Cc: | Trac Release: | 1.2 |
Description
The DataSaverPlugin (revision r15561) does not work with modern jquery versions.
It produces the following Javascript error $(...).unload is not a function
.
Running Trac 1.2.2, with Windows Firefox 63.
It looks like the problem is usage of the deprecated unload
function in the datasaver
JS routine:
$(window).unload(datasaver_savior) // DEPRECATED
The following the a proper replacement
$(window).on("unload",datasaver_savior)
This is what I learned from Denys Séguret at stackoverflow:
This function was first deprecated in 1.8 and then removed. You could in theory replace it with
.on("unload", function(){
which it was a shortcut for.
But it was removed for a good reason: listening for this event is usually a bad practice. The truth is there's no real cross-browser and reliable solution to handle page termination. The real solution is to avoid relying on this event. You must design your application so that you don't have anything to do on page closing.
Attachments (0)
Change History (8)
comment:1 Changed 6 years ago by
comment:2 follow-up: 5 Changed 6 years ago by
Replying to clemens:
The DataSaverPlugin (revision r15561) does not work with modern jquery versions.
It does work with the versions of jQuery distributed with Trac (see JavaScript). Using a newer version is not recommended.
comment:3 follow-up: 6 Changed 6 years ago by
Owner: | set to Ryan J Ollos |
---|---|
Resolution: | → fixed |
Status: | new → closed |
In 17318:
comment:4 Changed 6 years ago by
Owner: | changed from Ryan J Ollos to clemens |
---|
comment:5 follow-up: 7 Changed 6 years ago by
Replying to Ryan J Ollos:
It does work with the versions of jQuery distributed with Trac (see JavaScript). Using a newer version is not recommended.
According to JavaScript Trac 1.2.x should come with 1.11.3. But it seems my TRAC (version 1.2.2, Debian 9 "stretch" linux server) is running with jQuery 3.2.1. Firefox debug console says:
jQuery.fn.jquery "3.2.1"
I have no idea why I have this jQuery version. We did not mess around with that...
I invested deeper, but was not able to find out why.
First I disabled all plugins - for testing.
But my chrome/common/js/jquery.js
is version 3.2.1.
We installed Trac as Debian package (i.e. not from source) and my guess is that Debian package makers bundled another jQuery version. On my debian server I found a soft-link in /usr/lib/python2.7/dist-packages/trac/htdocs/js/jquery.js
which point to a file /usr/share/javascript/jquery/jquery.min.js
. This JS file jQuery version 3.2.1. I expect this is the case why my Trac is served with that jQuery version.
Bottom line is: Ryan, you are right, I am running the "wrong" (too new) jQuery version with TRAC. But I have no idea what is the background. Since you fixed the issue #13509, I have no problem with my jQuery version. If you believe I should dig into this, then I might ask also on the mailing list. Maybe we have some Debian TRAC experts there. Otherwise I would keep it as it is.
comment:6 follow-up: 8 Changed 6 years ago by
Replying to Ryan J Ollos:
Fixes #13509.
Wow, Ryan. You are fast!
I never expect you are doing overnight service.
Many, many thanks for your diligent commitment to TRAC.
Clemens
comment:7 Changed 6 years ago by
Replying to clemens:
We installed Trac as Debian package (i.e. not from source) and my guess is that Debian package makers bundled another jQuery version.
Yeah, I've seen other reports on that as well. I'm surprised it doesn't cause more problems. If it ever becomes an issue, the easiest thing fix would be to use jQuery and jQuery-UI from a CDN (see TracIni#trac-jquery_location-option). But if it's working, I would not worry about it.
comment:8 Changed 6 years ago by
Replying to clemens:
Wow, Ryan. You are fast!
I never expect you are doing overnight service. Many, many thanks for your diligent commitment to TRAC.
Easy to do since you provided the patch. Thanks!
In 17317: