SearchClass
This class provides an user interface allowing the user to search for things supported by the adapter nokia.mh5.components.Search.searchAdapter, remembers and shows the completion of the previous searches. You can disable or modify the shown completion and specify your own search back-end logic. If you just need a headless search, we recommend to use the search function of the adapter directly. To step in and influence the default behavior of the component define you own listeners for the component.
Example
var search = new nokia.mh5.components.Search({
searchAdapter: mySearchAdapter,
completionAdapter: myCompletionAdapter,
input: {
placeholder: "Search...",
listeners: {
focus: function(e) {
//my focus handler
}
}
},
listeners: {
beforesearch: function(e) {
//my beforesearch handler
},
success: function(e) {
//my success handler
},
error: function(e) {
//my error handler
},
clear: function(e) {
//my clear handler
}
},
parameters: {
limit: 25,
center: function() {
return this.page.map.center;
}
}
});
document.body.appendChild(search.root);
Inheritance hierarchy
nokia.mh5.Classnokia.mh5.ui.Control
nokia.mh5.ui.Container
nokia.mh5.components.Search
Constructor Detail
Constructor of the search component.
new nokia.mh5.components.Search(props, parentContainer);
Constructor Parameters
| Type | Name | Description |
|---|---|---|
| Object | props | properties of the component. You can overwrite every property or function of this component. See the example in class description above. Additional to that you can define the listeners property |
| nokia.mh5.ui.Container | parentContainer | parent container of the search component |
| Object | listeners | Object where you can define your own listeners for the offered events |
| Function | beforesearch | Handler called before the search function is called. You can find the query saved in the "data" property of the received event. If you want to prevent search for special user entries, call preventDefault function on the received event. |
| Function | clear | Handler called when the user clears the previous search query. |
| Function | success | Handler called when the search is done. You can find the received data in the "data" property of the received event. |
| Function | error | Handler called when the search has failed. If the error is known, you can find the error message in the "data" property of the received event. |
Methods Hide Inherited
![]() ![]() |
insertBefore | Inserts a control with a specified name to the container before the control with the specified name and adds the "parent" property set to the container to it. |
![]() ![]() |
add | Adds a control with the specified name to the container and adds the "parent" property set to the container to it. |
![]() ![]() |
getContentRoot | Returns the real DOM node of the control without scroll wrapper (if present). |
![]() ![]() |
getRootOwnerByClass | Retrieves the instance that owns the root node of the specified Class. Used to retrieve creator of the component inside bound events. |
![]() ![]() |
prepareBindings | Calls prepareBindings on children controls (if available) and itself. |
![]() ![]() |
prepareDidChangeNotifications | Calls prepareDidChangeNotifications on children controls (if available) and itself. |
![]() ![]() |
remove | Removes a specified a control from the container, if it can be found. |
![]() |
search | You can trigger the search by calling this function. It passes the current value of nokia.mh5.components.Search.query and nokia.mh5.components.Search.parameters to the search function of nokia.mh5.components.Search.adapter. It calls "success"/"error" listeners after the adapter calls the callback/errback of the component itself. The search results will be passed as a parameter to the success listener. |
Properties Hide Inherited
![]() |
nokia.mh5.ui.List | completion | List containing entries provided by nokia.mh5.components.Search.completionAdapter. To disable the completion set the nokia.mh5.components.Search.completionAdapter to null. The list shows the value of the "text" property in nokia.mh5.ui.List.items. |
![]() |
Object | completionAdapter | Adapter used to get and add entries from/to the completion. This default completion is based on the previous user search queries and suggestions delivered by the Nokia suggestion service. To disable the completion functionality set this property to null |
![]() ![]() |
Boolean | dontBind | makes sure, that the bindings in the container are initialized after the build function of all children is called. |
![]() |
nokia.mh5.ui.TextInput | input | Control representing the text input field for user input. |
![]() |
Object | parameters | Parameters are passed to nokia.mh5.components.Search#adapter.search function. The properties can be either primitives or functions. In the last case the functions will be called in the context of the search component. |
![]() |
String | query | Search query bound to the nokia.mh5.ui.TextInput.value property. |
![]() |
nokia.mh5.adapters.Search | searchAdapter | Adapter used to execute search. To enable your own back-end search service define you own adapter. It should provide search function with the same interface our default adapter does. |
Events
nokia.mh5.components.Search has no events.
Callbacks
nokia.mh5.components.Search has no callbacks.
Classes
nokia.mh5.components.Search has no classes.
Constants
![]() ![]() |
Object | n.a. | SEARCH_COMPLETION | default adapter for completions the user see typing a new query |
Interfaces
nokia.mh5.components.Search has no interfaces.


