Reputation: 166
I've been using scrollTo.js for a while now and everything worked great.
However, I decided to change the structure of my website files and now, scrollTo.js fires this error:
Uncaught TypeError: Failed to execute 'scroll' on 'Window': 2 arguments required, but only 1 present.
Here is my HTML:
<body class="scrolltoJS">
<section id="1">
<%content%>
<div id="about_scroll" onclick="scroll('#clients')">
<p>CLIENTS</p>
</div>
</section>
<section id="clients">
<%content%>
</section>
</body>
Here is the JS
if($('body').is('.scrolltoJS')){
function scroll(parameter){
$(parameter).ScrollTo();
}
}
Here is my test landing page - http://aux.socialook.net/test_site/themes/index.html . Just click on the square button - Find Out More
Upvotes: 1
Views: 3023
Reputation: 166
I found the solution. The problem was that the scrollTO function was in another function that was firing initially but then wasn't available when calling the different functions in it.
code looked like this:
$(function(){
if($('body').is('.scrolltoJS')){
function scroll(parameter){
$(parameter).ScrollTo();
}
}
Upvotes: 0
Reputation: 207501
window.scroll(x,y) is already defined so your code is trying to call that. My guess is that scroll function you defined is not being registered or you are defining it in another scrope that is not window.
Upvotes: 1