mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-10-31 09:03:06 +00:00 
			
		
		
		
	pedagogy: auto send form when typing
This commit is contained in:
		| @@ -16,7 +16,7 @@ | |||||||
| 	</p> | 	</p> | ||||||
| 	{% endif %} | 	{% endif %} | ||||||
| 	<p> | 	<p> | ||||||
| 		<input class="input-search" type="text" name="search"> | 		<input id="search_input" class="input-search" type="text" name="search"> | ||||||
| 		<button class="button-search">{% trans %}Search{% endtrans %}</button> | 		<button class="button-search">{% trans %}Search{% endtrans %}</button> | ||||||
| 	</p> | 	</p> | ||||||
| 	<div class="radio-guide"> | 	<div class="radio-guide"> | ||||||
| @@ -118,6 +118,20 @@ | |||||||
| 		return html + "</td>"; | 		return html + "</td>"; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	var lastTypedLetter; | ||||||
|  | 	$("#search_input").on("keyup", function(){ | ||||||
|  | 		// Auto submit when user pauses it's typing | ||||||
|  | 		clearTimeout(lastTypedLetter); | ||||||
|  | 		lastTypedLetter = setTimeout(function (){ | ||||||
|  | 			$("#search_form").submit(); | ||||||
|  | 		}, 300); | ||||||
|  | 	}); | ||||||
|  | 	$("#search_input").on("change", function(e){ | ||||||
|  | 		// Don't send request when leaving the text area | ||||||
|  | 		// It has already been send by the keypress event | ||||||
|  | 		e.preventDefault(); | ||||||
|  | 	}); | ||||||
|  |  | ||||||
| 	// Auto fill from get arguments | 	// Auto fill from get arguments | ||||||
| 	var urlParams = new URLSearchParams(window.location.search); | 	var urlParams = new URLSearchParams(window.location.search); | ||||||
| 	if (urlParams.has("search")) | 	if (urlParams.has("search")) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user