diff options
| author | Teddy Wing | 2017-03-18 16:08:32 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2017-03-18 16:08:32 +0100 | 
| commit | d2fc72cd520a1a505ae710279603506b16fd9a09 (patch) | |
| tree | 45fa12fa79b945958dae79719d6486b83711f868 /timetasker.js | |
| parent | 4ce9ebcf4f3339e55670d98434e8b6f1f4f8d9ad (diff) | |
| download | chrome-timetasker-d2fc72cd520a1a505ae710279603506b16fd9a09.tar.bz2 | |
Fire change event on project select box
Remove our timeouts for the moment to focus on getting the Module
select box populated.
Fire a change event on the Project select box using the technique
and code described here:
http://stackoverflow.com/questions/2856513/how-can-i-trigger-an-onchange-event-manually/2856602#2856602
Diffstat (limited to 'timetasker.js')
| -rw-r--r-- | timetasker.js | 24 | 
1 files changed, 15 insertions, 9 deletions
| diff --git a/timetasker.js b/timetasker.js index 8fae786..fdb4346 100644 --- a/timetasker.js +++ b/timetasker.js @@ -19,17 +19,17 @@  	popupate_select(client_0, CLIENT); -	popupate_select(project_0, PROJECT); -	// need to add a damn event trigger in order to get options to load + +	fire_select_event( +		popupate_select(project_0, PROJECT) +	); +  	window.setTimeout(function() {  		popupate_select(module_0, MODULE); -	}, 1500); -	window.setTimeout(function() { -		popupate_select(task_0, TASK); -	}, 500); -	window.setTimeout(function() { -		popupate_select(work_type_0, WORK_TYPE);  	}, 500); + +	popupate_select(task_0, TASK); +	popupate_select(work_type_0, WORK_TYPE);  	// popupate_select(date_0, '');  	time_0.value = TIME;  	popupate_select(billable_0, BILLABLE ? 't' : 'f'); @@ -41,8 +41,14 @@  		for (var i = 0; i < options.length; i++) {  			if (options[i].textContent === name) {  				element.value = options[i].value; -				return; +				return element;  			}  		}  	} + +	function fire_select_event(element) { +		var event = document.createEvent('HTMLEvents'); +		event.initEvent('change', false, true); +		element.dispatchEvent(event); +	}  })(); | 
