NG launch instance: Clear fileInput value on text change
The onchange event occurs when a control loses the input focus and its value has been modified since gaining focus. This attribute applies to the following elements: INPUT, SELECT, and TEXTAREA. http://www.w3.org/TR/html4/interact/scripts.html#adef-onchange This affected uploading a script and modifying it, as it would not allow to reupload it again. This patch cleans the fileInput.val() on textInput change so a user can upload a script, modify it, and reupload the same script again if he wants to start from a clean scratch again Change-Id: Ie2d29de4ebcdea07f7e3e2ce6c7094c1d2fe5e10 Closes-Bug: #1522067
This commit is contained in:
parent
e1f07e2794
commit
d2692ef801
|
@ -77,6 +77,23 @@
|
|||
textarea.on('input propertychange', onTextareaChange);
|
||||
fileInput.on('change', onFileLoad);
|
||||
|
||||
/* onchange event occurs when a control loses the input focus and
|
||||
* its value has been modified since gaining focus so we need to clear
|
||||
* up the fileInput.val() when the textContent field is modified as to
|
||||
* allow reloading the same script.
|
||||
*/
|
||||
var textContentWatcher = $scope.$watch(function () {
|
||||
return $scope.textContent;
|
||||
}, function () {
|
||||
if (fileInput.val() !== "") {
|
||||
fileInput.val(null);
|
||||
}
|
||||
}, true);
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
textContentWatcher();
|
||||
});
|
||||
|
||||
function onTextareaChange() {
|
||||
$scope.$applyAsync(function () {
|
||||
/* Angular model won't provide the value of the <textarea> when it is in
|
||||
|
|
Loading…
Reference in New Issue