* Minor JS bugfix to allow uploading multiple files via the web interface

This commit is contained in:
Ross Poulton 2008-02-08 00:48:23 +00:00
parent 41a3199513
commit d6196e540d

View File

@ -11,18 +11,13 @@
return false; return false;
}); });
processAddFileClick();
$("#ShowFileUpload").click(function() { $("#ShowFileUpload").click(function() {
$("#FileUpload").fadeIn(); $("#FileUpload").fadeIn();
$("#ShowFileUploadPara").hide(); $("#ShowFileUploadPara").hide();
return false; return false;
}); });
$(".AddAnotherFile").click(function() {
$(this).hide();
$("#FileUpload>dl").append("<dt><label>Attach another File</label></dt><dd><input type='file' name='attachment' id='file' /> (<a href='#' class='AddAnotherFile'>Add Another File</a>)</dd>");
return false;
});
$('#id_preset').change(function() { $('#id_preset').change(function() {
preset = $('#id_preset').val(); preset = $('#id_preset').val();
if (preset != '') { if (preset != '') {
@ -32,6 +27,18 @@
} }
}); });
}); });
function processAddFileClick() {
/* Until jQuery includes some 'livequery' functionality in the core
distribution, this will have to do. */
$(".AddAnotherFile>a").click(function() {
$(this).parent().hide();
$("#FileUpload>dl").append("<dt><label>Attach another File</label></dt><dd><input type='file' name='attachment' id='file' /> <span class='AddAnotherFile'>(<a href='#'>Add Another File</a>)</span></dd>");
processAddFileClick();
return false;
});
}
</script> </script>
{% endblock %} {% endblock %}
@ -163,8 +170,7 @@
<dl> <dl>
<dt><label for='id_file'>Attach a File</label></dt> <dt><label for='id_file'>Attach a File</label></dt>
<dd><input type='file' name='attachment' id='file' /> (<a href='#' class='AddAnotherFile'>Add Another File</a>)</dd> <dd><input type='file' name='attachment' id='file' /> <span class='AddAnotherFile'>(<a href='#'>Add Another File</a>)</span></dd>
</dl> </dl>
</div> </div>