Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Auto next on single question: Difference between revisions

From Catglobe Wiki
Created page with "To make single questions automatically go to next question when an answer option has been selected, put the script on questionnaire's javascript of editor <source lang="javas..."
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Questionnaire]]
To make single questions automatically go to next question when an answer option has been selected, put the script on questionnaire's javascript of editor
To make single questions automatically go to next question when an answer option has been selected, put the script on questionnaire's javascript of editor


<source lang="javascript">
<source lang="javascript">
//after getting new questions to show
AnswerSheet.bind('afterShowPage', function(ev, as) {
AnswerSheet.bind('afterShowPage', function(ev, as) {
//check current is Single Question
//find all of single questions
if (as.questions.length != 1) return;
as.questions.match('type', 1).map(function(q){
var q = as.questions[0];
//and run this function after the value has changed
if (q.type != 1) return;
q.answerOptions.bind('selectionChanged', function() {
//auto next
q.answerOptions.bind('selectionChanged', function() {
var ao = this.getAnswer()[0];
var ao = this.getAnswer()[0];
if (!ao || ao.open) return; //ignore Open answer
if (!ao || ao.open) return; //ignore Open answer
as.moveToNextPage();
//Use the new onTriggerEnterKey if possible or fallback to moveToNextPage
if (typeof as.onTriggerEnterKey === "function") as.onTriggerEnterKey(q);
else as.moveToNextPage(); //backwards compatible
});
});
});
});
});
</source>
</source>


[[File:2020-10-15_14-24-58.jpg]]
[[File:2020-10-19_09-50-58.jpg]]
 
 
[[Category:Questionnaire]]

Latest revision as of 02:52, 19 October 2020


To make single questions automatically go to next question when an answer option has been selected, put the script on questionnaire's javascript of editor

//after getting new questions to show
AnswerSheet.bind('afterShowPage', function(ev, as) {
//find all of single questions
	as.questions.match('type', 1).map(function(q){
//and run this function after the value has changed
		q.answerOptions.bind('selectionChanged', function() {
		var ao = this.getAnswer()[0];
		if (!ao || ao.open) return; //ignore Open answer
//Use the new onTriggerEnterKey if possible or fallback to moveToNextPage
		if (typeof as.onTriggerEnterKey === "function") as.onTriggerEnterKey(q);
		else as.moveToNextPage(); //backwards compatible
	});
	});
});