The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Back to top button

2 posters

Go down

Solved Back to top button

Post by lightningterror February 13th 2013, 6:38 am

Hello ,

I'm trying to add a "Back to top" button on my forum however the code doesn't work , can anyone help me out with this?

The code I'm using is from http://davidwalsh.name/jquery-top-link

The error I'm getting is

Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'scrollTo' 30305.js:1
(anonymous function) 30305.js:1
f.event.dispatch jquery.min.js:3
f.event.add.h.handle.i
lightningterror
lightningterror
Forumember

Male Posts : 45
Reputation : 5
Language : English

http://hellguards.nice-forum.com/

Back to top Go down

Solved Re: Back to top button

Post by lightningterror February 13th 2013, 6:41 am

In a widget.
lightningterror
lightningterror
Forumember

Male Posts : 45
Reputation : 5
Language : English

http://hellguards.nice-forum.com/

Back to top Go down

Solved Re: Back to top button

Post by lightningterror February 13th 2013, 6:44 am

I put the javascript in the Javascript codes management (checked it in all pages) , and css in the CSS Stylesheet
lightningterror
lightningterror
Forumember

Male Posts : 45
Reputation : 5
Language : English

http://hellguards.nice-forum.com/

Back to top Go down

Solved Re: Back to top button

Post by lightningterror February 13th 2013, 7:31 am

Code:
jQuery.fn.topLink = function(settings) {
  settings = jQuery.extend({
    min: 1,
    fadeSpeed: 200
  }, settings);
  return this.each(function() {
    //listen for scroll
    var el = $(this);
    el.hide(); //in case the user forgot
    $(window).scroll(function() {
      if($(window).scrollTop() >= settings.min)
      {
        el.fadeIn(settings.fadeSpeed);
      }
      else
      {
        el.fadeOut(settings.fadeSpeed);
      }
    });
  });
};

//usage w/ smoothscroll
$(document).ready(function() {
  //set the link
  $('#top-link').topLink({
    min: 400,
    fadeSpeed: 500
  });
  //smoothscroll
  $('#top-link').click(function(e) {
    e.preventDefault();
    $.scrollTo(0,300);
  });
});

The problem must be smoothscroll effect because without it the code works.

edit: nvm about this code , found a working one at http://gazpo.com/2012/02/scrolltop/

you can lock the topic Smile
lightningterror
lightningterror
Forumember

Male Posts : 45
Reputation : 5
Language : English

http://hellguards.nice-forum.com/

Back to top Go down

Solved Re: Back to top button

Post by Sanket February 13th 2013, 8:54 am

Topic Solved & Locked
Sanket
Sanket
ForumGuru

Male Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum