vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Keep div hidden on different page (https://vborg.vbsupport.ru/showthread.php?t=317452)

Dave Strider 02-22-2015 07:07 AM

Keep div hidden on different page
 
I currently have this code:
Code:

$(document).ready(function(){
    $("#hide").click(function(){
        $("#menu").hide(500);
    });
    $("#show").click(function(){
        $("#menu").show(500);
    });
});

What I would like to do is for it to remember the users selection. Essentially if the user is on the home page and chooses to hide the menu, it will stay hidden while they are on a different page.

Dr.CustUmz 02-22-2015 08:33 AM

what you need is an Oreo =)
take a look at this, seems you understand what you're doing. So im going to point you in the right direction
Double Stuffed Oreo's
Chocolate Chip Cookies

Dave Strider 02-22-2015 11:13 PM

Quote:

Originally Posted by Dr.CustUmz (Post 2538262)
what you need is an Oreo =)
take a look at this, seems you understand what you're doing. So im going to point you in the right direction
Double Stuffed Oreo's
Chocolate Chip Cookies

I have no clue what I'm doing with jQuery. I found this code online lol.

greigeh 02-23-2015 03:50 PM

Here is something what you're looking for, I use this on my forum as an alternative to the confusing templates that is used within vB3. You can alter this to suit your needs

Code:

$(document).ready(function() {
// LEFT COLUMN:
        // When the collapse button is clicked:
        $('.collapseLeft_20').click(function() {
                $('.collapseLeft_20').css("display","none");
                $('.expandLeft_20').css("display","block");
                $('#leftCol_20').css("display","none");
                $.cookie('leftCol_20', 'collapsed');
        });
        // When the expand button is clicked:
        $('.expandLeft_20').click(function() {
                $('.expandLeft_20').css("display","none");
                $('.collapseLeft_20').css("display","block");
                $('#leftCol_20').css("display","block");
                $.cookie('leftCol_20', 'expanded');
        });
// COOKIES
        // Left column state
        var leftCol_20 = $.cookie('leftCol_20');
        // Set the user's selection for the left column
        if (leftCol_20 == 'collapsed') {
                $('.collapseLeft_20').css("display","none");
                $('.expandLeft_20').css("display","block");
                $('#leftCol_20').css("display","none");
        };
});


Dave Strider 02-24-2015 02:08 AM

Quote:

Originally Posted by greigeh (Post 2538404)
Here is something what you're looking for, I use this on my forum as an alternative to the confusing templates that is used within vB3. You can alter this to suit your needs

Code:

$(document).ready(function() {
// LEFT COLUMN:
        // When the collapse button is clicked:
        $('.collapseLeft_20').click(function() {
                $('.collapseLeft_20').css("display","none");
                $('.expandLeft_20').css("display","block");
                $('#leftCol_20').css("display","none");
                $.cookie('leftCol_20', 'collapsed');
        });
        // When the expand button is clicked:
        $('.expandLeft_20').click(function() {
                $('.expandLeft_20').css("display","none");
                $('.collapseLeft_20').css("display","block");
                $('#leftCol_20').css("display","block");
                $.cookie('leftCol_20', 'expanded');
        });
// COOKIES
        // Left column state
        var leftCol_20 = $.cookie('leftCol_20');
        // Set the user's selection for the left column
        if (leftCol_20 == 'collapsed') {
                $('.collapseLeft_20').css("display","none");
                $('.expandLeft_20').css("display","block");
                $('#leftCol_20').css("display","none");
        };
});


It still appears when going to a new page even if it was hidden on the previous one.

Dr.CustUmz 02-24-2015 07:01 AM

did you modify it to fit your classes? take the time to read the links i shared, get an understanding of what you're trying to accomplish, you should have no issue adapting grieg's code.

http://stackoverflow.com/questions/1...ie-with-jquery

if your looking more for a "will you do it for me" and not actually wanting to learn anything, share your template

Dave Strider 02-24-2015 10:49 AM

Quote:

Originally Posted by Dr.CustUmz (Post 2538523)
did you modify it to fit your classes? take the time to read the links i shared, get an understanding of what you're trying to accomplish, you should have no issue adapting grieg's code.

http://stackoverflow.com/questions/1...ie-with-jquery

if your looking more for a "will you do it for me" and not actually wanting to learn anything, share your template

Well I just solved the issue. I forgot to include jquery.cookie.js file. I probably should have double checked to see if that was included. Honest mistake really. Thanks for the help!

greigeh 02-24-2015 07:35 PM

Sorry I should really have mentioned you needed that file! Glad you got it to work though. :)


All times are GMT. The time now is 03:57 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01212 seconds
  • Memory Usage 1,741KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete