From: Bryan Date: Thu, 19 Dec 2013 23:06:26 +0000 (-0500) Subject: Fixing multiple upload problem by removing anonymous save function out of an iterated... X-Git-Tag: release-20150131~376^2~13 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cad933dfc63c3bc3563a93a50159b686f20fc4ae;p=oweals%2Fkarmaworld.git Fixing multiple upload problem by removing anonymous save function out of an iterated function call closing #211 --- diff --git a/karmaworld/templates/partial/filepicker.html b/karmaworld/templates/partial/filepicker.html index edad646..615b95d 100644 --- a/karmaworld/templates/partial/filepicker.html +++ b/karmaworld/templates/partial/filepicker.html @@ -104,50 +104,49 @@ }); document.getElementById('save-btn').style.display = 'inline'; + } - $('#save-btn').on('click', function(e){ - e.stopPropagation(); - $('#forms_container .inline-form').each(function(i,el){ - console.log("inline form " + i + "el: " + el); - var name, tags, fpurl, course; - name = $(el).find('.intext').val(); - fp_file = $(el).find('.fpurl').val(); - tags = $(el).find('.taggit-tags').val(); - course = $(el).find('.course_id').val(); - csrf = $(el).find('.csrf').val(); - mimetype = $(el).find('.mimetype').val(); + $('#save-btn').on('click', function(e){ + e.stopPropagation(); + $('#forms_container .inline-form').each(function(i,el){ + console.log("inline form " + i + "el: " + el); + var name, tags, fpurl, course; + name = $(el).find('.intext').val(); + fp_file = $(el).find('.fpurl').val(); + tags = $(el).find('.taggit-tags').val(); + course = $(el).find('.course_id').val(); + csrf = $(el).find('.csrf').val(); + mimetype = $(el).find('.mimetype').val(); - $.post('{% url 'upload_post' %}', { - 'name': name, - 'fp_file': fp_file, - 'tags': tags, - 'course': course, - 'csrfmiddlewaretoken': csrf, - 'mimetype': mimetype - }, function(data){ - if (data === 'success') { - // For multiple uploads, we may end up clearing and re- - // writing this multiple times, but show the same list - // each time. - $('#uploaded_files').empty(); - for (var i=0; i < uploaded_files.length; i++) { - $('#uploaded_files').append($('
  • ', {text: uploaded_files[i]})); - } - $('#success').show(); - document.getElementById('save-btn').style.display = 'none'; - $('#forms_container .inline-form').remove(); - _gat._getTracker()._trackEvent('upload', 'upload form submitted'); - setTimeout(function(){ - location.reload(true); - }, 15000); + $.post('{% url 'upload_post' %}', { + 'name': name, + 'fp_file': fp_file, + 'tags': tags, + 'course': course, + 'csrfmiddlewaretoken': csrf, + 'mimetype': mimetype + }, function(data){ + if (data === 'success') { + // For multiple uploads, we may end up clearing and re- + // writing this multiple times, but show the same list + // each time. + $('#uploaded_files').empty(); + for (var i=0; i < uploaded_files.length; i++) { + $('#uploaded_files').append($('
  • ', {text: uploaded_files[i]})); } - }); - // Add the name we've just uploaded to the list - uploaded_files.push(name); - }); + $('#success').show(); + document.getElementById('save-btn').style.display = 'none'; + $('#forms_container .inline-form').remove(); + _gat._getTracker()._trackEvent('upload', 'upload form submitted'); + setTimeout(function(){ + location.reload(true); + }, 15000); + } + }); + // Add the name we've just uploaded to the list + uploaded_files.push(name); }); - - }; + }); var fileup = document.getElementById('filepicker-file-upload'); fileup.onchange = function(event){