- Posts: 41
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Upload modal - Strange behavior after upgrade to version 5
- squidy
- Topic Author
- Offline
- Senior Member
Less
More
5 months 4 weeks ago #251619
by squidy
Using LS 5.x
Replied by squidy on topic Upload modal - Strange behavior after upgrade to version 5
Hi again, Tony..
I am facing a problem with this script.
When the participant uploads a file to the modal and clicks save page to finish later, the file disappears. But this only happens if the participant clicks save on the same modal page.
Do you know what happens?
I am facing a problem with this script.
When the participant uploads a file to the modal and clicks save page to finish later, the file disappears. But this only happens if the participant clicks save on the same modal page.
Do you know what happens?
Using LS 5.x
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
5 months 3 weeks ago #251662
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Upload modal - Strange behavior after upgrade to version 5
Try this:
Code:
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify the questions var qArrayID = '{QID}'; var qArray = $('#question'+qArrayID); var arrayLength = $('tr[id^="javatbd"]', qArray).length; var qUploads = qArray.nextAll('.upload-files:lt('+arrayLength+')'); // Add some classes qArray.addClass('array-with-uploads-question'); $(qUploads).addClass('hidden'); // Insert the "Upload" buttons $('tr[id^="javatbd"] .answer-item:last-child', qArray).each(function(i) { $('*', this).remove(); $(this).append('<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#upload-'+qArrayID+'-'+(i+1)+'" data-backdrop="static" data-keyboard="false">Anexar comprovante</button>'); }); // Loop through the upload questions $(qUploads).each(function(i) { // Create a modal $('body').append('<div class="modal upload-modal" id="upload-'+qArrayID+'-'+(i+1)+'" tabindex="-1" role="dialog">\ <div class="modal-dialog" role="document">\ <div class="modal-content">\ <div class="modal-header">\ <h5 class="modal-title">'+$('.ls-label-question', this).html()+'</h5>\ </div>\ <div class="modal-body">\ </div>\ <div class="modal-footer">\ <button type="button" class="btn btn-primary" data-bs-dismiss="modal">OK</button>\ </div>\ </div>\ </div>\ </div>'); // Move this question into the modal $('#upload-'+qArrayID+'-'+(i+1)+' .modal-body').append($(this)); $(this).removeClass('hidden'); }); // Interrupt the Next/Submit function (to put upload questions back in the form) $('#limesurvey').on('submit', function(e) { $('.upload-modal .upload-files').appendTo($('.group-container:eq(0)')).addClass('hidden'); }); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in to join the conversation.
- squidy
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 41
- Thank you received: 1
5 months 3 weeks ago #251675
by squidy
Using LS 5.x
Replied by squidy on topic Upload modal - Strange behavior after upgrade to version 5
Brilliant... Thank you again...
Using LS 5.x
Please Log in to join the conversation.