- Posts: 48
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify the questions var thisQID = {QID}; var thisQuestion = $('#question'+thisQID); var subquestionsLength = $('.answer-item', thisQuestion).length; var qUploads = thisQuestion.nextAll('.upload-files:lt('+subquestionsLength+')'); // Add some classes $(qUploads).each(function(i) { $(this).addClass('uploads-question index-'+i).css({ 'position': 'absolute', 'left': '-9999em' }); }); // Insert the uploads buttons $('.answer-item', thisQuestion).each(function(i) { $('input:text', this).after('<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#uploads-'+thisQID+'-'+(i+1)+'" data-backdrop="static" data-keyboard="false">Upload</button>'); }); // Handle uploads questions $(qUploads).each(function(i) { // Create modals $('body').append('<div class="modal uploads-modal" id="uploads-'+thisQID+'-'+(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">Close</button>\ </div>\ </div>\ </div>\ </div>'); // Move the Upload questions into modals $('#uploads-'+thisQID+'-'+(i+1)+' .modal-body').append($('.ls-answers', this)); }); // Interrupt the Next/Submit function (to put comments back in the form) $('#limesurvey').submit(function(e) { $('.uploads-modal[id^="uploads-'+thisQID+'-"]').each(function(i) { var qID = $('input:eq(0)', this).attr('id').split('X')[2]; $('#question'+qID+' .answer-container').append($('.ls-answers', this)); }); }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify the questions var thisQID = {QID}; var thisQuestion = $('#question'+thisQID); var subquestionsLength = $('.answer-item', thisQuestion).length; var qUploads = thisQuestion.nextAll('.upload-files:eq(0)'); // Add some classes $(qUploads).addClass('uploads-question index-'+i).css({ 'position': 'absolute', 'left': '-9999em' }); // Insert the comments buttons $('.answer-item:last', thisQuestion).each(function(i) { $('input:text', this).after('<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#uploads-'+thisQID+'-'+(i+1)+'" data-backdrop="static" data-keyboard="false">Upload</button>'); }); // Handle comments $(qUploads).each(function(i) { // Create modals $('body').append('<div class="modal uploads-modal" id="uploads-'+thisQID+'-'+(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">Close</button>\ </div>\ </div>\ </div>\ </div>'); // Move the Upload questions into modals $('#uploads-'+thisQID+'-'+(i+1)+' .modal-body').append($('.ls-answers', this)); }); // Interrupt the Next/Submit function (to put comments back in the form) $('#limesurvey').submit(function(e) { $('.uploads-modal[id^="uploads-'+thisQID+'-"]').each(function(i) { var qID = $('input:eq(0)', this).attr('id').split('X')[2]; $('#question'+qID+' .answer-container').append($('.ls-answers', this)); }); }); }); </script>