输入字段中的 OnKeyup 与部分刷新相关,在最后一个退格键上不起作用
我用 XPage 编写了一个网页。我有一个输入字段,当值更改时会触发 onkeyup 事件。在 onkeyevent 中,我触发了包含数据视图的 div 的部分刷新。我使用用户输入的内容对数据进行子集化。例如,该列表可能以
Alan 开头 布拉德 布莱恩 账单 Chad
如果用户输入“B”,那么我们就只剩下中间的三个名字,如果他们为“Br”添加一个 r,我们就只剩下 Brad 和 Bryan 等等。
如果用户退格,则过程相反。
一切都很完美,但有一个问题。当用户退格以使输入字段为空时,视图应恢复为所有名称,但事实并非如此,它保持与只有 1 个字母时相同。如果我再次退格,那么视图将获得所有值。
我已经为此奋斗了一个小时但没有成功,非常感谢任何帮助。
谢谢,
布莱恩
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否使用 viewScope 变量来控制视图内容?
我有一个用于视图的过滤工具,当键入(onKeyUp)时,数据将写入 viewScope.query。在 viewPanel 上设置部分刷新视图
的数据我已将“在视图结果中搜索:”设置为 viewScope.query
尝试添加检查 viewScope.query 是否不为空,然后发回 viewScope.query
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