WinJS.Resources.addEventListener function
Registers an event handler for the specified event. Use this method to register for events that are related to resources, such as when the app's language, scale, or contrast changes.
Syntax
WinJS.Resources.addEventListener(type, listener, useCapture);
Parameters
type
Type: StringThe name of the event to handle.
listener
Type: FunctionThe listener (event handler function) to associate with the event.
useCapture
Type: BooleanSet to true to register the listener for the capturing phase; otherwise, set to false to register the listener for the bubbling phase.
Return value
This function does not return a value.
Examples
This example is based on scenario 6 of the Application resources and localization sample. See the sample for the more complete solution.
var output;
var page = WinJS.UI.Pages.define("/html/scenario6.html", {
ready: function (element, options) {
output = document.getElementById('output');
WinJS.Resources.processAll(output); // Refetch string resources
WinJS.Resources.removeEventListener("contextchanged", refresh, false);
WinJS.Resources.addEventListener("contextchanged", refresh, false);
}
});
Requirements
Minimum WinJS version |
WinJS 1.0 |
Namespace |
WinJS.Resources |