Questions tagged «typeahead»

11
停止输入/书写后如何触发输入文本中的事件?
我想在我停止在输入文本框中键入(而不是在键入时)字符之后触发事件。 我尝试过: $('input#username').keypress(function() { var _this = $(this); // copy of this object for further usage setTimeout(function() { $.post('/ajax/fetch', { type: 'username', value: _this.val() }, function(data) { if(!data.success) { // continue working } else { // throw an error } }, 'json'); }, 3000); }); 但是此示例为每个键入的字符产生超时,如果输入20个字符,我将收到20个AJAX请求。 在这个小提琴上,我用简单的警报而不是AJAX演示了相同的问题。 有没有解决的办法,或者我只是用一种不好的方法呢?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.