locked
update toggleswitch in settings flyout

    Question

  • Hi 

    i have a toggleswitch in my settings flyout, whereby a user can change whether to run the app online or offline, but when i change the toggle, the setting doesnt stay. for example when the setting flyout is opened, the toggleswitch is "off", now if i turn it on, i expect it to stay "on"

    the code for the toggleswitch:

    <div id="offline_mode" data-win-control="WinJS.UI.ToggleSwitch" data-win-options="{}">

    i have an event listener

    document.getElementById("offline_mode").addEventListener("onchange", changeMode, false);

    the changeMode method

     function changeMode() {
    
                var toggleOnline = document.getElementById("offline_mode").winControl;
                
               
                toggleOnline.checked = 1 ;
    WinJS.UI.process(toggleOnline);
                WinJS.UI.processAll();
            }
        }

    I am completely lost, can someone point me in the right direction please.

    Thank you

    Sasha

    Tuesday, October 29, 2013 1:50 PM

Answers

  • Hi Jeff 

    thanks for making me re-look at the sample, i have to got it to work now :)

    when the page loads i checked if my variable was true/false and updated the toggle accordingly, on the "change" event listener I set the value of my variable based on whether the toggle is on/off.

    Thanks again 

    Sasha 

    • Marked as answer by Sasha_za Thursday, October 31, 2013 8:01 AM
    Thursday, October 31, 2013 8:00 AM

All replies