survey-library: Routing on first page does not work.
Describe the bug We have a survey that has routing on the first visible page like this:
{
"pages": [
{
"name": "page1",
"visibleIf": "{group} = 2",
...
We initialize data for this survey like this:
const survey = new Survey.Model(json);
survey.setValue('group', 2);
...
survey.render(document.getElementById("surveyElement"));
When the survey is rendered we see page2, not page 1.
Steps to reproduce
- Go to (https://plnkr.co/edit/jFj1iqoHEEYqtN3V)
- Note that you start on the second page, there is a previous button visible
Expected behavior I’d expect to be shown the first page, because according to the conditions the question should be visible.
Screenshots
Please complete the following information:
- Browser: [e.g. chrome, safari] N/A
- Browser version: [e.g. 22] N/A
- JS framework/library: [e.g. React, Angular, Vue 2 or 3, Knockout, jQuery, Vanilla JS] Vanilla
- SurveyJS version: [e.g. v1.12.7] v2.0.9
- Device: [e.g. PC, iPhone 6] N/A
Additional context Full survey json:
const json ={
"pages": [
{
"name": "page1",
"visibleIf": "{group} = 2",
"elements": [
{
"type": "text",
"name": "question1"
},
{
"type": "radiogroup",
"name": "question4",
"choices": [
"Item 1",
"Item 2",
"Item 3"
]
}
]
},
{
"name": "page2",
"elements": [
{
"type": "text",
"name": "question2"
}
]
},
{
"name": "page3",
"elements": [
{
"type": "text",
"name": "question3"
}
]
}
]
};
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (16 by maintainers)
@SamMousa This code makes the perfect sense if you want to increase the performance for a large survey. So you do not run all expressions two times, with empty data and then with the assign data. However, I beleive the following code would lead to the same result:
My idea was a little different. Let’s say you want to store your survey progress and you want to restore later the entered data & the current page. Since currentPage (name and no) doesn’t make sense for some modes then
currentElementNamewould solve this issue.@SamMousa Could you please propse the code, because I am likely do not understand the issue you are trying to solve.