lundi 23 mai 2016

Continuing to Show/Hide a div based off user selection throughout time on website

I currently have a section on my website (site is constructed in Laravel 5) which the user can show/hide. It is essentially a greeting from me. At the moment, all I am doing is using jQuery .toggle() on the element to show/hide. The issue is, when a user visits a different page the element re-appears (because it wasn't hidden originally).

I have considered just using AJAX for my sub pages and not refreshing the page, as there is very little content here anyway, but I was wondering if there is a better way to just pass session variables or cookies to different views and continue to hide the div.

HTML:

<div class="container">
    <div class="row-fluid welcome-container">
        <div class="col-md-3 profile">
            <img class="profile-picture" src="images/jon.jpg">
        </div>
        <div class="col-md-9 welcome-box">
            <div class="welcome">
                <h2>
                    Welcome to my website.
                    <hr>
                </h2>
            </div>
            <p class="hide-welcome">
                <a href="#">[-]</a>
            </p>
        </div>
    </div>
    <p class="show-welcome">
        <a href="#">[+]</a>
    </p>
</div>

JS:

$(".hide-welcome").click(function() {
    $(".welcome-container").slideToggle(500, "swing");
    $(".hide-welcome").css("display", "none");
    $(".show-welcome").css("display", "block");
    var hidden = 1;
});
$(".show-welcome").click(function() {
    $(".welcome-container").slideToggle(500, "swing");
    $(".show-welcome").css("display", "none");
    $(".hide-welcome").css("display", "block");
    var hidden = 0;
});

I figure if I can pass 'hidden' along to each view via a Session/Cookie I could just run a blade check on that variable and then either hide/show the div at page load. Is there an easy way to do this, or should I just do AJAX loading of body content (and never leave the home page)?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1OKaDhx
via IFTTT

Aucun commentaire:

Enregistrer un commentaire