¡@

Home 

2014/10/16 ¤W¤È 12:05:25

jquery Programming Glossary: min_time_between_requests

How to run a function once when binding to multiple events that all trigger in Javascript?

http://stackoverflow.com/questions/13900093/how-to-run-a-function-once-when-binding-to-multiple-events-that-all-trigger-in-j

here in JSFiddle . document .ready function var inputIntance #test input var lastInputValue var valueCheckTimer var MIN_TIME_BETWEEN_REQUESTS 100 100ms var lastCheckWasAt 0 function checkInputValue lastCheckWasAt getTimeStamp var newValue inputIntance.val if newValue.. Date .getTime function checkInputValueScheduled if valueCheckTimer check is already planned it will be performed in MIN_TIME_BETWEEN_REQUESTS return else no checks planned if getTimeStamp lastCheckWasAt MIN_TIME_BETWEEN_REQUESTS check was more than MIN_TIME_BETWEEN_REQUESTS.. planned it will be performed in MIN_TIME_BETWEEN_REQUESTS return else no checks planned if getTimeStamp lastCheckWasAt MIN_TIME_BETWEEN_REQUESTS check was more than MIN_TIME_BETWEEN_REQUESTS ago checkInputValue else check was not so much time ago schedule new check..