Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter mrcoulson

    (@mrcoulson)

    Hey!

    The site we have is just one page and all of the nav links point to #anchor elements on the page. That was working a-okay. Then we needed to add a contact form as a separate page but with the same nav items. So, I just added the /so the anchors are /#anchor. That way, the same nav can be used on the contact form page to point to site root #anchor.

    Example: <a href="/#features">Features and Pricing</a> refers to either “go to an anchor called features on this page” or “go to an anchor called features on the home page” if you’re on the \contact page. Does that make sense?

    Here’s what I did to the code:

    Right at the top of the ('a[href*=#]').click() function, I check to see what the first character in the href is:

    var intSubstrIndex; // To set substr index.
    	// If the anchor begins with a /...
    	if (jQuery(this).attr("href").charAt(0) == "/") {
    		intSubstrIndex = 2;
    	}
    	else {
    		intSubstrIndex = 1;
    	}

    Then set the index for substr for offset and top. Like:

    var offset = jQuery('[name="' + jQuery.attr(this, 'href').substr(intSubstrIndex) + '"]').offset();

    That way I’m altering it so I get “features” whether the href is “/#features” or “#features”.

    I don’t know if it’s something that would be useful in the official version. As it is, it’s really specific for us.

    Jeremy

    Thread Starter mrcoulson

    (@mrcoulson)

    Hey, there. I actually figured it out yesterday and didn’t get to come back here and post about it yet. It’s really sort of embarrassing. I had some JavaScript referencing an element on the page and then I removed that element but forgot about the JavaScript and it caused an error that broke the plugin. I started to try to debug the plugin and found the JS error in the console and realized what mistake I had made. I did, however, end up tweaking the plugin’s JS to handle a / before the #anchorname since some of our nav links are coded like href="/#anchorname".

    Nonetheless, awesome plugin. Very easy to use if you don’t make an unrelated dumb JavaScript error ??

    Thanks for getting back in touch! Have an awesome day!

    Thread Starter mrcoulson

    (@mrcoulson)

    This afternoon, I gave IUSR complete permissions to the root of my entire website — the WordPress parts and the not-WordPress parts. Then my auto update worked. Naturally, I don’t want to have to do this. Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)