I am developing a 9.13 DotNetNuke custom module and on one of my settings pages a have a custom input field to upload files to my API controller, but whenever I try to make ANY ajax request to the server, DNN automatically replaces my file input field styles, so it creates a span with dnnInputFileWrapper
class, and it overrides my original input field. Additionally, it removes event handlers. Here is how my DOM looks before the ajax request:
<div class="btn btn-primary btn-file" tabindex="500">
<i class="bi-folder2-open"></i>
<span class="hidden-xs">Browse …</span>
<input id="my-input" type="file" multiple="">
</div>
And after:
<div class="btn btn-primary btn-file" tabindex="500">
<i class="bi-folder2-open"></i>
<span class="hidden-xs">Browse …</span>
<span class="dnnInputFileWrapper dnnSecondaryAction">Choose File
<input id="my-input" type="file" multiple="">
</span>
</div>
And UI looks like so:
I tried to overwrite the default DotNetNuke CSS classes and it worked fine until I faced the problem with removed event handlers
I've found the answer. If you're facing the problem you should add the
normalFileUpload
class to your input fieldtype="file"
.After inspecting DotNetNuke dnn.jquery.js file I found the function which handles the wrapping functionality and the line of code which allow us to avoid this behaviour and it looks like this:
At least it works with DNN version 9.13