Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
2219 Представления

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.

Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
окт. 18
3733
2
дек. 22
6250
5
янв. 22
11876
1
авг. 16
5235
1
мая 25
8425