Handling Search Activation

After a user enters query text in the Search pane and submits their query then you need to display search results from your app. You can detect when your app is activated in response to a search by listening for the activated event and checking whether the ActivationKind property has the value search.

The My Notes app uses the code in Listing 13.5 to detect search activation. This code is contained in the default.js file.

LISTING 13.5 Handling Search Activation (js\default.js)

app.addEventListener("activated", function (args) {    // Navigate to search results on search    if (args.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.search) {        return WinJS.Navigation.navigate( ...

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.