Hi, I am developing a custom module to create several pages on a website. Does anyone know how to load a js file for each page? I ask that because If you load on web.assets.frontend 1 file this is executed every time you navigate on every page.
Cette question a été signalée
1
Répondre
3289
Vues
Hi,
One thing you could do is check window.location.href == 'the page url' and then write the functions required for the page, or if there’s a specific class to identify the page, you can find it using jQuery and then write the code inside that.
if($(‘identifier)) {
function
}Or you can add the script in the XML so that it only loads when the specific page loads.
Regards
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrire| Publications associées | Réponses | Vues | Activité | |
|---|---|---|---|---|
|
|
1
oct. 18
|
4828 | ||
|
|
2
déc. 22
|
8237 | ||
|
|
5
janv. 22
|
13766 | ||
|
|
1
août 16
|
6448 | ||
|
|
1
mai 25
|
9848 |