- Posts: 26
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Yes, you need to place a copy of that function in your template.js file. It will override the core function.One note:
you said "You can overwrite the core updateDragDropRank() function in template.js and insert the ranked numbers"
but in the template.js I haven't the updateDragDropRank() function.
What am I doing wrong?
function updateDragDropRank(qID){ var maxanswers= parseInt($("#ranking-"+qID+"-maxans").text().trim(),10); var rankingname= "javatbd"+$("#ranking-"+qID+"-name").text().trim(); var relevancename= "relevance"+$("#ranking-"+qID+"-name").text().trim(); var rankingnamewidth=rankingname.length; $('#question'+qID+' .select-item select').val(''); $('#sortable-rank-'+qID+' li').each(function(index) { // Get value of ranked item var liID = $(this).attr("id"); liValue = liID.substr(rankingnamewidth); $('#question'+qID+' .select-item select').eq(index).val(liValue); }); // Update #relevance and lauch checkconditions function $("[id^=" + relevancename + "]").val('0'); $('#question'+qID+' .select-item select:lt('+maxanswers+')').each(function(index){ number=index+1; if($(this).val()!="") { $("#"+relevancename+number).val("1"); } $(this).trigger("change",{ source : 'dragdrop'}); }); $('#sortable-rank-'+qID+' li').removeClass("error"); $('#sortable-choice-'+qID+' li').removeClass("error"); $('#sortable-rank-'+qID+' li:gt('+(maxanswers*1-1)+')').addClass("error"); // Numbers for ranked items $('#question'+qID+' .rank-number').remove(); $('#question'+qID+' .dragDropRankList li').each(function(i) { $(this).prepend('<span class="rank-number">'+(i+1)+':</span>'); }); }
.rank-number { display: inline-block; margin-right: 5px; color: #FF0000; }