EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

WinJS.Utilities.createEventProperties function

Applies to Windows and Windows Phone

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 supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1

Namespace

WinJS.Utilities

Library

Base.js

 

 

Afficher:
© 2014 Microsoft