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

WinJS.UI.SearchBox object

Applies to Windows only

Enables the user to perform search queries and select suggestions.

Syntax


<div 
    data-win-control="WinJS.UI.SearchBox">
</div>


var object = new WinJS.UI.SearchBox();

Members

The SearchBox object has these types of members:

Constructors

The SearchBox object has these constructors.

ConstructorDescription
SearchBox

Creates a new SearchBox.

 

Events

The SearchBox object has these events.

EventDescription
onquerychanged

Raised when the user or the app changes the queryText.

onquerysubmitted

Raised awhen the user clicks the search glyph or presses Enter.

onreceivingfocusonkeyboardinput

Raised when the app automatically redirects focus to the search box. This event can only be raised when the focusOnKeyboardInput property is set to true.

onresultsuggestionchosen

Raised when the user selects a suggested option for the search.

onsuggestionsrequested

Raised when the system requests search suggestions from this app.

 

Methods

The SearchBox object has these methods.

MethodDescription
addEventListener

Registers an event handler for the specified event.

createResultSuggestionImage

Creates the image argument for appending result suggestions when handling the suggestionsrequested event.

dispatchEvent

Raises an event of the specified type and with additional properties.

dispose

Releases resources held by this SearchBox. Call this method when the SearchBox is no longer needed. After calling this method, the SearchBox becomes unusable.

removeEventListener

Removes an event handler that the addEventListener method registered.

setLocalContentSuggestionSettings

Specifies whether suggestions based on local files are automatically displayed in the search pane, and defines the criteria that Windows uses to locate and filter these suggestions.

 

Properties

The SearchBox object has these properties.

PropertyAccess typeDescription

chooseSuggestionOnEnter

Read/write

Gets or sets whether the first suggestion is chosen when the user presses Enter.

disabled

Read/write

Gets or sets a value that specifies whether the SearchBox is disabled. If the control is disabled, it won't receive focus.

element

Read/write

Gets the DOM element that hosts the SearchBox.

focusOnKeyboardInput

Read/write

Gets or sets a value that specifies whether the search box automatically receives focus when the user types into the app window.

placeholderText

Read/write

Gets or sets the placeholder text for the SearchBox. This text is displayed if there is no other text in the input box.

queryText

Read/write

Gets or sets the query text for the SearchBox.

searchHistoryContext

Read/write

Gets or sets the search history context. This context is used a secondary key (the app ID is the primary key) for storing search history.

searchHistoryDisabled

Read/write

Gets or sets a value that specifies whether search history is disabled.

 

Remarks

For more info, see Guidelines for search.

Note  An app can't use both the search box (Windows.UI.Xaml.Controls.SearchBox for Windows Store apps using C++, C#, or Visual Basic, WinJS.UI.SearchBox for Windows Store apps using JavaScript) and the SearchPane. Using both the search box and the search pane in the same app causes the app to throw an exception with this message: "Cannot create instance of type 'Windows.UI.Xaml.Controls.SearchBox.'"

Requirements

Minimum supported client

Windows 8.1 [Windows Store apps only]

Minimum supported server

Windows Server 2012 R2 [Windows Store apps only]

Minimum supported phone

None supported

Namespace

WinJS.UI

Library

Ui.js

See also

Quickstart: Adding search to an app

 

 

Afficher:
© 2014 Microsoft