Click here to Skip to main content
15,900,714 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can you help me please. I'm trying to add the easing function to the $.scrollTo part of this block of code. So far all I get is errors, I can achieve easing when function(){ is not tagged onto the end. Thank you in advance

<script type="text/javascript"> 
function scrollToTopB(){	
$.scrollTo('0px', 800, function() {
$("#box1").animate({'width':'500px','height':'1278px'},500, function() {
document.getElementById('main').height="1278";
});
})
}
</script>


Note - I also have these in the head
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery.scrollTo.js"></script>
<script type="text/javascript" src="jquery.easing.1.3.js"></script>
Posted

To make sure you elements are all created and the script is not running before the page load you should wrap your entire code block in a 'document ready' section.

<script type="text/javascript"> 
$(function(){
 ...your code here
});
</script>


If this doesn't fix it, what are the errors you're getting?
 
Share this answer
 
I'm a little confused. You mentioned I should wrap my entire code block in a 'document ready' section. I also have three similiar blocks of code but with different heights. Do they also get wrapped in the document ready section?
More info - The function scrollTopTopS(){ is what I trigger with my swf using AS2. With your document ready section how does flash trigger the function? Could you give an example.

Here's my current script. Maybe you can spot an error.
<script type="text/javascript"> 
function scrollToTopS(){
$.scrollTo('0px', 800, {easing:'easeOutQuad'}, function() {
$("#flash").animate({'width':'500px','height':'800px'},500, function() {
document.getElementById('main').height="800";
});
})
}
</script>


Forgive my lack of intelligence on the above. This is my third week of jquery and more indepth html use. I mainly use flash timeline & AS2 although I'm trying to broaden my script knowledge.
Many Thanks
 
Share this answer
 
Hello James.
Just to let you know I've got it working with your help.
Many Thanks.
 
Share this answer
 
Comments
TheyCallMeMrJames 25-Jun-10 21:43pm    
No worries, glad I could help. the idea is that when you work with jQuery you have a little mutual agreement in place: you promise to make sure the DOM is loaded before you call jQuery, and it promises to work as expected across browsers ;o) In re-reading your original code I am seeing that you weren't actually making the call there, just defining a function. In reality, if you don't have anything calling that code until the document is fully loaded, you don't have to worry about things. I'm glad it seemed to point you in the right direction.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900