Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Location
    London
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 'blind.js' toggle only works on homepage page

    Greetings too all, here is my personal website.

    Situation

    I have a relatively simple few lines of javascript that allow me to slideToggle a div (#main-content-info) into (and back out of) display. The div begins with its display set to none and when the header buttons at the top of the page are clicked, (#main-content-info) slides into display.

    Problem

    The function stops working when you navigate to other pages in the site (by using the "Browse Portfolio" drop down).

    Question
    How do I allow this function to perform on all pages of the site?

    Please see code below.

    Code:
    $(document).ready(function(){
    	$(".slide-button-one").click(function(){
    		$("#main-content-info").slideToggle(600,function(){
    		$("#main-content-portfolio").toggle();
    		});
    		return false;
    	});
    });
    Thank you for your time and I would appreciate any responses, long or short – including "don't do it like that, do it like this."

    Rob
    Last edited by Robert Mayers; 09-26-2011 at 09:18 PM. Reason: 1st post! So please do let me know if my post is not acceptable.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Include the code in all the pages of your website where you want it to function. It will not somehow carry forward to another page.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Location
    London
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you. I see what you mean.

    I actually thought that is what I had achieved. I am using wordpress so the link to the javascript file is within <head>, inside the header.php file. It is just above my other javascript file link for my navigation drop down menu function.

    Must I also include link to the code within the page.php file then? I thought it would be called automatically as the first thing that page.php does is 'get_header'.

    I hope my poor understanding of javascript does not appear to be antagonising.
    Last edited by Robert Mayers; 09-26-2011 at 10:49 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •