Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3923 Visualizzazioni

Why 'window.addEventListener("hashchange",...' or 'window.onhashchange' JS events are not working on odoo15 backend? Whereas they are working fine until odoo14. What has changed? Or any other workaround for this event? I am not able to capture the changes of hash values of URLs while traversing in the backend in odoo 15 only. They are working fine in odoo 13,14 etc.

Avatar
Abbandona
Autore

In Odoo 15, the backend URL structure has changed, so the hashchange event is no longer triggered when navigating between pages. This is because the URL now uses a route system rather than hashes to indicate the current page.

To detect changes in the current route, you can use the odoo.__DEBUG__.services['web_tour.tour'].router.current_route variable in your JavaScript code. You can listen for changes to this variable and perform any necessary actions when it is updated.

Alternatively, you can use the web_tour.tour service to listen for route changes and trigger your custom code. Here is an example:

odoo.define('my_module.route_listener', function (require) {
'use strict';

var Tour = require('web_tour.tour');

Tour.register({
id: 'my_route_listener',
name: 'My route listener',
path: '/web', // or any other route you want to listen to
mode: 'test',
onChange: function (page, next) {
// your custom code here
// `page` is the current route
next();
},
});
});

Post correlati Risposte Visualizzazioni Attività
2
dic 22
2520
2
mag 22
13811
2
apr 22
4011
1
apr 22
3073
1
nov 19
18421