Delay execution of a function until stop typing

An example showing how to delay execution of a function until stop typing using Tizen 2.3.
<!DOCTYPE html>
<html>
<body>

<input type="text" />

<script>
var handle = null;
var delay = 1000;
var callback = function() {
  console.log('callback');
};
document.querySelector('input').addEventListener('keyup', function(e) {
  if (handle) {
    clearTimeout(handle);
  }
  handle = setTimeout(callback, delay);
});
</script>

</body>
</html>

Responses

0 Replies