Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Page & Category Menu Bars »

Trying to make pages menu sticky - javascript trouble?


  #1  
Old Sep 25, 2012, 10:44 AM
crashley1784
 
81 posts · May 2009
Hey all,

I'm trying to make the pages menu on the site I'm working on stick to the top of the page when the user scrolls down, following the tutorial here: http://www.dwuser.com/education/cont...vigation-menu/

I've followed the steps, making the (what I thought were) necessary tweaks to the javascript for ata.
Here is the javascript:
Code:
$(function() {
    // Stick the #nav to the top of the window
    var nav = $('#nav');
    var navHomeY = nav.offset().top;
    var isFixed = false;
    var $w = $(window);
    $w.scroll(function() {
        var scrollTop = $w.scrollTop();
        var shouldBeFixed = scrollTop > navHomeY;
        if (shouldBeFixed && !isFixed) {
            nav.css({
                position: 'fixed',
                top: 0,
                left: nav.offset().left,
                width: nav.width()
            });
            isFixed = true;
        }
        else if (!shouldBeFixed && isFixed)
        {
            nav.css({
                position: 'static'
            });
            isFixed = false;
        }
    });
});
​
I placed the javascript in the HTML Inserts: header field. Is this where I need to put it? Or should I place it in one of the core theme files?

I changed
Code:
var nav = $('#nav');
to include first the ul# for the menu (ul#rmenu2), and when that didn't work I tried using the containing div id (menu1).

Neither is working.
I know next to nothing about javascript or jquery (it's on my todo list), so any help with this would be greatly appreciated.

Link to site: http://www.laurenacooper.com/ohprefresh
  #2  
Old Sep 25, 2012, 11:12 AM
juggledad's Avatar
juggledad
 
23,655 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
why not put the menu at the top to start and fix it with css?
HTML Code:
div#menu1 {position: fixed !important; top: 0 !important;}
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Sep 25, 2012, 12:50 PM
crashley1784
 
81 posts · May 2009
Because we want the menu bar to be beneath the logo, and only stick to the top of the page as the user scrolls down.
  #4  
Old Sep 25, 2012, 01:41 PM
juggledad's Avatar
juggledad
 
23,655 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
You should contact the author of the code and ask them for advice
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Sep 25, 2012, 02:43 PM
crashley1784
 
81 posts · May 2009
Ok, fair enough. Can you please tell me though if I am putting the code in the right place? HTML inserts > head? Or would I need to put it in a theme file somewhere?
  #6  
Old Sep 25, 2012, 02:51 PM
juggledad's Avatar
juggledad
 
23,655 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
That seems like the logical place, but I didn't read their documentation so I can't be 100% sure. but it should go somewhere in the 'Add HTML/CSS Inserts' options and not in a theme file.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Last edited by juggledad; Sep 26, 2012 at 08:25 AM.
  #7  
Old Sep 26, 2012, 08:23 AM
crashley1784
 
81 posts · May 2009
Thanks JD. Appreciate ya
  #8  
Old Sep 26, 2012, 09:24 PM
lmilesw's Avatar
lmilesw
 
10,174 posts · Jul 2009
Central New York State USA
Here is a menu plugin that doesn't do exactly as you want but... When you scroll down a defined distance a copy of your menu appears stuck to the top. You can see an example at the link.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Trouble controlling sticky intro post in liquid layout anartist Atahualpa 3 Wordpress theme 6 Sep 19, 2012 01:03 PM
How to make sticky posts with a large photo cwjorgensen Post-Kicker, -Byline & -Footer 1 Mar 6, 2011 03:09 PM
How do I make one custom link in the Pages Menu? kippiper Page & Category Menu Bars 22 Sep 5, 2010 08:20 PM
Make post sticky capetan Forum How-To 7 Apr 12, 2010 01:20 PM
[SOLVED] How to make Pages dropdown menu go UP :) Burn Menus 4 Nov 26, 2009 12:17 PM


All times are GMT -6. The time now is 07:33 PM.


Powered by vBulletin® Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.