WinJS.Utilities.createEventProperties function

Creates an object that has one event for each name passed to the function.

Syntax

var object = WinJS.Utilities.createEventProperties(events);

Parameters

  • events
    Type: object

    A variable list of property names.

Return value

Type: Object

The object with the specified properties. The names of the properties are prefixed with 'on'.

Examples

The following code shows how to use this function. It is commonly mixed with a previously-defined object in order to add events to the object.

<div id="result"></div>
<script type="text/javascript">
    var Person = WinJS.Class.define(
        function () {
            this.name = "Harry";
             this.color = "blue";
    });

    WinJS.Class.mix(
        Person,
        WinJS.Utilities.createEventProperties("change", "rename")
    );

    var myPerson = new Person();
    var div = document.getElementById("result");

    for (prop in myPerson)
         div.textContent += prop + " ";
</script>

// Output: name color onchange onrename

Requirements

Minimum WinJS version

WinJS 1.0

Namespace

WinJS.Utilities