콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
12934 화면

 I've created a custom theme module and have set up some javascript to handle hiding a utility bar that hides on scrolling.

I've installed the script in my theme/static/src/js folder  and created a my_theme.xml file in my views folder to add the script to the website.assets_frontend.

The script works great on the homepage - but stops working when you load the other pages (pages/contact_us, hello, etc). I can still see the script on all pages when I do a view source.

I'll insert a copy of the my_theme.xml and navbar.js

Thanks!

my_theme.xml:

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<template id="kdc_assets_frontend" inherit_id="website.assets_frontend" name="Sightac KDC Front End Assets">

<xpath expr="." position="inside">

<script src="/sightac_kdc/static/src/js/navbar.js"></script>

</xpath>

</template>

</data>

</openerp>


navbar.js:


$(window).scroll(function() {

if ($(".navbar").offset().top > 50) {

$('#custom-nav').addClass('utilityhide');

$(".navbar-fixed-top").addClass("top-nav-collapse");

} else {

$('#custom-nav').removeClass('utilityhide');

$(".navbar-fixed-top").removeClass("top-nav-collapse");

}

});

아바타
취소
작성자 베스트 답변

OK. Mystery solved. The home page includes a snippet that also run some script to manipulate a canvas. The internal pages don't have this snippet, which triggered a script error. All javascript stopped at that point including my navbar script.

아바타
취소

Could you please provide some more information on how you solved it then? Did you call the snippet for other pages or...

Can you anwser please ?

how did you solve this problem? since it's been my toothache, could you please leave full explanation of answer here please? maybe some examples etc.

관련 게시물 답글 화면 활동
1
3월 18
5666
0
3월 24
1487
0
2월 22
2790
0
2월 22
2350
1
8월 18
4226