OnKeyup in input field tied to partial refresh not working on last backspace

485 views Asked by At

I have written an web page in XPages. I have an input field that fires the onkeyup event when a value changes. In the onkeyevent I fire a partial refresh of a div that contains a view of data. I subset the data using what the user types. So, for example, the list may begin with

Alan Brad Bryan Bill Chad

If the user types "B" then we are left with only the middle three names, if they then add an r for "Br" we are left with only Brad and Bryan and so on.

If the user backspaces then the process is reversed.

It all works perfectly but for one problem. When the user backspaces such that the input field is blank the view should revert back to all names, but it doesn't, it stays just the same as when it had 1 letter. If I backspace AGAIN, THEN the view gets all values.

I have struggled with this for hour with no success and would really appreciate any help.

Thanks,

Bryan

1

There are 1 answers

0
Mikael Andersson Wigander On

Are you using a viewScope variable to control the view content?

I have a Filter Tool for my views where when typing (onKeyUp) the data is written to viewScope.query. the partial refresh is set on the viewPanel

The data of the view I have set the "Search in view results:" to viewScope.query

Try adding a check if viewScope.query is not null then send back the viewScope.query