dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36945
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18897: Resolve script error that tried to attach an event to a form element that did not exist when sett...
------------------------------------------------------------
revno: 18897
committer: Mark Polak <markpo@xxxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-04-14 11:21:56 +0200
message:
Resolve script error that tried to attach an event to a form element that did not exist when settings are not available
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/webapp/dhis-web-maintenance-appmanager/javascript/uploadApp.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/webapp/dhis-web-maintenance-appmanager/javascript/uploadApp.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/webapp/dhis-web-maintenance-appmanager/javascript/uploadApp.js 2013-11-04 20:56:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/webapp/dhis-web-maintenance-appmanager/javascript/uploadApp.js 2015-04-14 09:21:56 +0000
@@ -1,5 +1,11 @@
-function autoUpload() {
- document.getElementById('uploadPackageForm').addEventListener('change', function(e) {
+/* global jQuery */
+jQuery(function autoUpload() {
+ var uploadForm = document.getElementById('uploadPackageForm')
+
+ //If settings are not valid the form is not available.
+ if (uploadForm === null) { return; }
+
+ uploadForm.addEventListener('change', function(e) {
var fd = new FormData(document.getElementById('uploadPackageForm'));
var xhr = new XMLHttpRequest();
xhr.addEventListener('progress', function(e) {
@@ -31,6 +37,4 @@
xhr.open('post', 'addApp.action', true);
xhr.send(fd);
}, false);
-}
-
-$( document ).ready( autoUpload );
\ No newline at end of file
+});