Cache radio buttons jquery











up vote
0
down vote

favorite












I have this code:



@if (isset($isModelTranslatable) && $isModelTranslatable)
<div class="language-selector">
<div class="btn-group btn-group-sm" role="group" data-toggle="buttons">
@foreach(config('voyager.multilingual.locales') as $lang)
<label class="btn btn-primary{{ ($lang === config('voyager.multilingual.default')) ? " active" : "" }}">
<input type="radio" name="i18n_selector" id="{{$lang}}" autocomplete="off"{{ ($lang === config('voyager.multilingual.default')) ? ' checked="checked"' : '' }}> {{ strtoupper($lang) }}
</label>
@endforeach
</div>
</div>
@endif


I want do. If people click on radio button, remember this radio, and when reload page, do active radio button, which he selected. How I can do this? I can do with laravel cache? Or I need use jQuery caching?










share|improve this question






















  • have a look at localStorage but your question is too broad and therefore off topic for SO
    – Pete
    Nov 13 at 9:49

















up vote
0
down vote

favorite












I have this code:



@if (isset($isModelTranslatable) && $isModelTranslatable)
<div class="language-selector">
<div class="btn-group btn-group-sm" role="group" data-toggle="buttons">
@foreach(config('voyager.multilingual.locales') as $lang)
<label class="btn btn-primary{{ ($lang === config('voyager.multilingual.default')) ? " active" : "" }}">
<input type="radio" name="i18n_selector" id="{{$lang}}" autocomplete="off"{{ ($lang === config('voyager.multilingual.default')) ? ' checked="checked"' : '' }}> {{ strtoupper($lang) }}
</label>
@endforeach
</div>
</div>
@endif


I want do. If people click on radio button, remember this radio, and when reload page, do active radio button, which he selected. How I can do this? I can do with laravel cache? Or I need use jQuery caching?










share|improve this question






















  • have a look at localStorage but your question is too broad and therefore off topic for SO
    – Pete
    Nov 13 at 9:49















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have this code:



@if (isset($isModelTranslatable) && $isModelTranslatable)
<div class="language-selector">
<div class="btn-group btn-group-sm" role="group" data-toggle="buttons">
@foreach(config('voyager.multilingual.locales') as $lang)
<label class="btn btn-primary{{ ($lang === config('voyager.multilingual.default')) ? " active" : "" }}">
<input type="radio" name="i18n_selector" id="{{$lang}}" autocomplete="off"{{ ($lang === config('voyager.multilingual.default')) ? ' checked="checked"' : '' }}> {{ strtoupper($lang) }}
</label>
@endforeach
</div>
</div>
@endif


I want do. If people click on radio button, remember this radio, and when reload page, do active radio button, which he selected. How I can do this? I can do with laravel cache? Or I need use jQuery caching?










share|improve this question













I have this code:



@if (isset($isModelTranslatable) && $isModelTranslatable)
<div class="language-selector">
<div class="btn-group btn-group-sm" role="group" data-toggle="buttons">
@foreach(config('voyager.multilingual.locales') as $lang)
<label class="btn btn-primary{{ ($lang === config('voyager.multilingual.default')) ? " active" : "" }}">
<input type="radio" name="i18n_selector" id="{{$lang}}" autocomplete="off"{{ ($lang === config('voyager.multilingual.default')) ? ' checked="checked"' : '' }}> {{ strtoupper($lang) }}
</label>
@endforeach
</div>
</div>
@endif


I want do. If people click on radio button, remember this radio, and when reload page, do active radio button, which he selected. How I can do this? I can do with laravel cache? Or I need use jQuery caching?







php jquery laravel






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 at 9:19









Dumitru

213110




213110












  • have a look at localStorage but your question is too broad and therefore off topic for SO
    – Pete
    Nov 13 at 9:49




















  • have a look at localStorage but your question is too broad and therefore off topic for SO
    – Pete
    Nov 13 at 9:49


















have a look at localStorage but your question is too broad and therefore off topic for SO
– Pete
Nov 13 at 9:49






have a look at localStorage but your question is too broad and therefore off topic for SO
– Pete
Nov 13 at 9:49














1 Answer
1






active

oldest

votes

















up vote
0
down vote













jQuery doesn't have caching built in, but localStorage, like @Pete mentioned in the comments, is a good option. If you want to store data with Laravel, I'd suggest using an Eloquent model over caching, as it makes it easier (in my opinion) to associate unique data with a specific site visitor. (This is also assuming you have some sort of user login system preexisting.)



If you do choose to go the Laravel route, you'll have to send data over to your server when a user makes a selection, and then store it on the Laravel side. Research the fetch API or just make a simple HTML form.



For the most basic solution, localStorage remains your best bet. It's JavaScript-powered and stored on the client side, so you don't have to worry about cross-contaminating saved data or even storing data on your server at all. Wins all around! Take a look at this related answer on saving input states with localStorage, and let us know once you run into a specific issue.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53277583%2fcache-radio-buttons-jquery%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    jQuery doesn't have caching built in, but localStorage, like @Pete mentioned in the comments, is a good option. If you want to store data with Laravel, I'd suggest using an Eloquent model over caching, as it makes it easier (in my opinion) to associate unique data with a specific site visitor. (This is also assuming you have some sort of user login system preexisting.)



    If you do choose to go the Laravel route, you'll have to send data over to your server when a user makes a selection, and then store it on the Laravel side. Research the fetch API or just make a simple HTML form.



    For the most basic solution, localStorage remains your best bet. It's JavaScript-powered and stored on the client side, so you don't have to worry about cross-contaminating saved data or even storing data on your server at all. Wins all around! Take a look at this related answer on saving input states with localStorage, and let us know once you run into a specific issue.






    share|improve this answer

























      up vote
      0
      down vote













      jQuery doesn't have caching built in, but localStorage, like @Pete mentioned in the comments, is a good option. If you want to store data with Laravel, I'd suggest using an Eloquent model over caching, as it makes it easier (in my opinion) to associate unique data with a specific site visitor. (This is also assuming you have some sort of user login system preexisting.)



      If you do choose to go the Laravel route, you'll have to send data over to your server when a user makes a selection, and then store it on the Laravel side. Research the fetch API or just make a simple HTML form.



      For the most basic solution, localStorage remains your best bet. It's JavaScript-powered and stored on the client side, so you don't have to worry about cross-contaminating saved data or even storing data on your server at all. Wins all around! Take a look at this related answer on saving input states with localStorage, and let us know once you run into a specific issue.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        jQuery doesn't have caching built in, but localStorage, like @Pete mentioned in the comments, is a good option. If you want to store data with Laravel, I'd suggest using an Eloquent model over caching, as it makes it easier (in my opinion) to associate unique data with a specific site visitor. (This is also assuming you have some sort of user login system preexisting.)



        If you do choose to go the Laravel route, you'll have to send data over to your server when a user makes a selection, and then store it on the Laravel side. Research the fetch API or just make a simple HTML form.



        For the most basic solution, localStorage remains your best bet. It's JavaScript-powered and stored on the client side, so you don't have to worry about cross-contaminating saved data or even storing data on your server at all. Wins all around! Take a look at this related answer on saving input states with localStorage, and let us know once you run into a specific issue.






        share|improve this answer












        jQuery doesn't have caching built in, but localStorage, like @Pete mentioned in the comments, is a good option. If you want to store data with Laravel, I'd suggest using an Eloquent model over caching, as it makes it easier (in my opinion) to associate unique data with a specific site visitor. (This is also assuming you have some sort of user login system preexisting.)



        If you do choose to go the Laravel route, you'll have to send data over to your server when a user makes a selection, and then store it on the Laravel side. Research the fetch API or just make a simple HTML form.



        For the most basic solution, localStorage remains your best bet. It's JavaScript-powered and stored on the client side, so you don't have to worry about cross-contaminating saved data or even storing data on your server at all. Wins all around! Take a look at this related answer on saving input states with localStorage, and let us know once you run into a specific issue.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 at 19:02









        Sheng Slogar

        862414




        862414






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53277583%2fcache-radio-buttons-jquery%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?