artimys
4/14/2017 - 5:23 PM

Delay on Keyup Event

Delay on Keyup Event

	input_timer = undefined
	
	# Add keyup events to trigger an AJAX call
	$("#article_sections").on "keyup", "input", (e) ->

		input = $(this)
		clearTimeout input_timer if input_timer

		input_timer = setTimeout( ->
			$.ajax # Create AJAX 
				type: "POST"
				url:  input.data("url") + "&value=" + input.val()
		, 1000)