diff --git a/helpdesk/templates/helpdesk/ticket.html b/helpdesk/templates/helpdesk/ticket.html index 652988e0..ce7d61e4 100644 --- a/helpdesk/templates/helpdesk/ticket.html +++ b/helpdesk/templates/helpdesk/ticket.html @@ -266,71 +266,74 @@ $( function() { + {% if helpdesk_settings.HELPDESK_ENABLE_ATTACHMENTS %} + // this function listens for changes on any file input, and + // emits the appropriate event to update the input's text. + // Needed to have properly styled file input buttons! (this really shouldn't be this hard...) + $(document).on('change', ':file', function() { + var input = $(this), + inputWidgetNum = $(this).attr('id').split("file")[1], + numFiles = input.get(0).files ? input.get(0).files.length : 1, + label = input.val().replace(/\\/g, '/').replace(/.*\//, ''); + input.trigger('fileselect', [numFiles, label, inputWidgetNum]); + }); + {% endif %} + {% endblock %}