Freigeben über


Hub.addEventListener method

Registers an event handler for the specified event.

Syntax

hub.addEventListener(eventName, eventHandler, useCapture);

Parameters

  • eventName
    Type: String

    The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click".

  • eventHandler
    Type: Function

    The event handler function to associate with the event.

  • useCapture
    Type: Boolean

    Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase.

Return value

This method does not return a value.

Remarks

Setting event handlers declaratively (in HTML)

To set an event handler declaratively, it must be accessible to the global scope, and you must also call WinJS.Utilities.markSupportedForProcessing or WinJS.UI.eventHandler on the handler. You can make the handler accessible to the global scope by using WinJS.Namespace.define. For more information, see How to set event handlers declaratively.

Requirements

Minimum WinJS version

WinJS 2.0

Namespace

WinJS.UI

See also

Hub

HubSection

AppBar

NavBar

BackButton

Your first app - Part 3: PageControl objects and navigation

Quickstart: Using a hub control for layout and navigation

Navigating between pages (HTML)

Adding app bars

Adding nav bars

HTML Hub control sample

HTML AppBar control sample

HTML NavBar control sample

Navigation and navigation history sample

Designers

Command patterns

Navigation patterns

Hub

Guidelines for the hub control