Hello,
I have a requirement where user is typing in the input but length of the field is not fixed. I want to perform something when user stops typing. User is not pressing or doing anything. how can I call a function when user stops typing.
looking forward for suggestions.
Thanks,
Vanshika
Request clarification before answering.
See here for a example of delayed input.
It waits for 500 miliseconds and resets when the user types, so basically wait till the user stops typing.
public liveSearch(event: Event): void {
const value = (event.getParameter("value") as string).trim();
// delay search input
if (this.timerId) {
clearTimeout(this.timerId);
}
this.timerId = setTimeout(() => {
this.liveSearchHandler(value);
}, 500) as unknown as number;
}
public liveSearchHandler(value: string): void {
// const value = event.getParameter("value").trim();
this.getView().getModel("settings").setProperty("/search", value);
this.applySearch();
}
Hereis the input field:
<Input
placeholder="{i18n>app_view_search_placeholder}"
class="sapUiMediumMarginTopBottom"
id="multiInput"
width="100%"
liveChange=".liveSearch"
showSuggestion="false"
showValueHelp="false"
showTableSuggestionValueHelp="false"
value="{settings>/search}"
visible="{= ${settings>/route} !== 'RouteObjectView'}"
>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi vanshikachaturvedi3312 ,
please try to troubleshoot before you post your question here.
You rewrote the code i gave you.
Why did you use "window"? That just overrides the function and executes it immediately.
Try this:
this.timerId = setTimeout(function() {
this.liveSearchHandler(value);
}, 1000);
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.