Take the 2-minute tour ×

I'm very new to javascript, so this is confusing me. All of the settings charm tutorials only show how to put the controls into the settings charm, but none of them say how to find the information gotten in them. I tried to do one of these (like I do in the main program):

var muteToggle = document.GetElementById("Mute");

where "Mute" is the id in the separate html file. muteToggle just ends up being null all of the time. I tried putting it after

WinJS.UI.ProcessAll().then(function completed() {...

but that didn't work either. Everything else is the same as in this page: http://msdn.microsoft.com/en-us/library/windows/apps/hh780611.aspx

share|improve this question
JavaScript is case sensitive, is it be an ID of "mute" instead? –  Disco Banana Nov 29 '12 at 2:45
add comment

2 Answers

Make sure you're doing it in the ready function of the js file that is referenced from your settings HTML. Try opening the JavaScript console or QuickWatch while broken at that line and also look at the DOM Explorer to see if you can find your toggle control. You should be able to access it though. Also, try element.getElementById instead of document.getElementById. Either should work actually, but as long as you're troubleshooting. Good luck.

share|improve this answer
add comment

Your problem is that you are trying to get a reference to the HTML element from the code running during the app activation. Although that piece of code may define the HTML to be loaded for a settings pane, it does Not actually load the HTML into the DOM. You just simply can't get the instance from that location.

What you need to do is have the settings flyout have its own js file that implements IPageControlMembers. In particular, you need to implement the ready method. This method is called once all the HTML and controls are loaded for the page, including your toggle. The link has an example of how to do this.

Also see:

share|improve this answer
add comment

Your Answer


