开发者

.keyup not firing for delete of first char in input field

开发者 https://www.devze.com 2023-02-04 09:00 出处:网络
Strange phenomenon detected with JQuery 1.4.4 for FireF, Chrome, Safari (IE untestested). Aim: update a list while the user types a filter value into a simple, basic text-input-box.

Strange phenomenon detected with JQuery 1.4.4 for FireF, Chrome, Safari (IE untestested). Aim: update a list while the user types a filter value into a simple, basic text-input-box. Solution: bound keyup event, read out the value of the input-field, apply the filter... roughly:

$("#myinputfield").keyup(function(e) { myList.filter($(this).val()) });

it wo开发者_Python百科rks perfectly for both typing and deleting EXCEPT for when deleting (del or backspace same effect) the last remaining (==first) char. in that case the event does not fire at all. Anybody with an idea on what the problem is and/or how to solve it?

(p.s.: My solution would be to change from keyup event binding to a setTimeout periodical check as long as the input-field has focus, but that koxind of feels like a dirty escape...)


I cannot reproduce your problem. Perhaps it is just that your filter function does not handle $(this).val() == '' very well. Check out this quick test.

0

精彩评论

暂无评论...
验证码 换一张
取 消