Skip to content

Commit

Permalink
communitydebate/static/fileupload_formset: add event listener to dyna…
Browse files Browse the repository at this point in the history
…mically added fileupload forms
  • Loading branch information
Rineee authored and fuzzylogic2000 committed May 25, 2020
1 parent efbeb53 commit ecb8b34
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion euth/communitydebate/static/js/fileupload_formset.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* global $ django */
import { showFileName } from '../../../../euth_wagtail/assets/js/euth_wagtail';
(function (init) {
document.addEventListener('DOMContentLoaded', init, false)
document.addEventListener('a4.embed.ready', init, false)
Expand All @@ -21,10 +22,12 @@

DynamicFormSet.prototype.addForm = function () {
if (this.total < this.maxNum) {
var id = this.total
this.total += 1
this.$totalInput.val(this.total)
var newForm = getNewForm(this.$formTemplate, this.total - 1)
var newForm = getNewForm(this.$formTemplate, id)
$(newForm).insertBefore(this.$formTemplate)
document.getElementById(this.prefix + '-' + id.toString() + '-document').addEventListener('change', showFileName, false)
} else {
var text = django.gettext('Maximum number of upload documents reached.')
$('#error-max-num-forms').html('<ul class="errorlist"><li>' + text + '</li></ul>')
Expand Down

0 comments on commit ecb8b34

Please sign in to comment.