I created a module position at my template where I load a custom module which is a menu bar.
with the next script I change its position to fixed
if someone scrolls more than 200px
so that the bar will always be on top.
jQuery(window).scroll(function(e){
var jQueryel = jQuery('.fixedElement');
var isPositionFixed = (jQueryel.css('position') == 'fixed');
if (jQuery(this).scrollTop() > 200 && !isPositionFixed){
jQuery('.fixedElement').css({'position': 'fixed', 'top': '0px'});
jQuery('.fixedElement').addClass("bgNormal");
}
if (jQuery(this).scrollTop() < 200 && isPositionFixed)
{
jQuery('.fixedElement').css({'position': 'absolute', 'top': '0px'});
jQuery('.fixedElement').removeClass("bgNormal");
}
});
I added this script inside the head of template. It runs smoothly in every page except of the views
of a custom component
I made.
Console doesn't output any error and inspecting the source code I can find that the script is loaded correctly. For some reason it just wont run.
jQuery
is correctly loaded and I cant think of anything that would affect the view to run the js.
I uploaded another component
and I found that it wouldn't run the script either.
Is this a common issue ? Do I have to do something in order to load scripts from template to view ? Or it's a development problem ?