Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-09-2009, 10:35 PM   PM User | #1
naseem
New to the CF scene

 
Join Date: Dec 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
naseem is an unknown quantity at this point
jquery scrollto and blinking before performing action in firefox

Hy, just registered, I'm a total newby on j.s. having some problem with the plugin as well, you can see code and problem at this page (work in progress), www.silentbreeze-yurt.com , what happens in firefox and some other browsers as well is that when the button up is pressed for a moment it blinks the header of page and then back to the movement ftom bottom up to top page, it's as if the link is followed first and then the plug in enters and perform the task afterwords,
Code:
<script>jQuery(function( $ ){
		//borrowed from jQuery easing plugin
		//http://gsgd.co.uk/sandbox/jquery.easing.php
		$.scrollTo.defaults.axis = 'xy'; return false;
		});</script>
and here is the html:

<div id="bottom">
<div id="up" >
<a href="#" onclick="$.scrollTo( '#header', 900 );">up</a>
</div>
</div> <!-- bottom -->
naseem is offline   Reply With Quote
Old 12-10-2009, 12:03 AM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
One of the advantages to using jQuery is you can write unobtrusive Javascript. That is to say, you can get rid of all Javascript in your html markup-- for example, that "onclick=" you are using, you should put that in your jQuery scripting instead of in your html.

This may fix your problem too.
__________________
Fumigator is offline   Reply With Quote
Old 12-10-2009, 09:30 AM   PM User | #3
Iszak
Regular Coder

 
Iszak's Avatar
 
Join Date: Jun 2007
Location: Perth, Western Australia
Posts: 332
Thanks: 2
Thanked 58 Times in 57 Posts
Iszak is an unknown quantity at this point
What you described is caused by the fact that it's still executing the default behavior of a click to avoid this you either use return false or event.preventDefault(); e.g. (assuming the same mark-up)
Code:
$('#up a').click(function(){
  $.scollTo('#header', 900);

  return false;
});

// Alternatively you can do
$('#up a').click(function(event){
  $.scollTo('#header', 900);

  event.preventDefault(); 
});

// Or using your current code
<div id="bottom">
  <div id="up">
    <a href="#" onclick="$.scrollTo( '#header', 900 ); return false;">up</a>
  </div>
</div>
You may want to change the selector to something more appropriate if using the first two examples, and as Fumigator stated you want to try and stay away from inline events such as onclick and use code like what I provided you with.

It's basically the same concept behind the separation of content (HTML) and presentational (CSS) except we're throwing in the behavioral layer (JS).

Last edited by Iszak; 12-10-2009 at 09:33 AM..
Iszak is offline   Reply With Quote
Old 12-11-2009, 06:37 PM   PM User | #4
naseem
New to the CF scene

 
Join Date: Dec 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
naseem is an unknown quantity at this point
solved

thanks both for help, solved
naseem is offline   Reply With Quote
Reply

Bookmarks

Tags
jquery, scrollto

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:43 PM.


Advertisement
Log in to turn off these ads.