ISurveyOptions
Options passed as the second argument to the SurveyModel constructor. The constructor reads these options once, before loading the survey JSON.
import { SurveyModel, type ISurveyOptions } from "survey-core";
const options: ISurveyOptions = {
runtimeSettings: {
// Configure how the survey behaves at runtime
},
events: {
// Register handlers before the survey JSON loads
},
propertyDefaults: {
// Set property defaults by class
}
};
// Pass your survey JSON as the first argument
const survey = new SurveyModel(surveyJson, options);
Attaches one or more handlers to each specified survey event.
To attach multiple handlers to the same event, pass them in an array in the order they should run. To remove a handler, pass the original function to the event's remove() method.
import { SurveyModel } from "survey-core";
function logQuestionName(_, { question }) {
console.log(question.name);
}
function logQuestionType(_, { question }) {
console.log(question.getType());
}
const survey = new SurveyModel(surveyJson, {
events: {
onQuestionCreated: [logQuestionName, logQuestionType]
}
});
survey.onQuestionCreated.remove(logQuestionName);
You can also attach a handler with the event's
.add()method after creating the survey. By then, the constructor has loaded any survey JSON passed to it, and the handler runs the next time the event is raised. Use theeventsobject instead if you need to handle events raised during that load.
- Type:
- SurveyEventHandlers readonly
- Implemented in:
- ISurveyOptions
Sets property defaults by class.
An unset property uses the nearest class default in the inheritance chain, with the Serializer default as a fallback.
import { SurveyModel } from "survey-core";
const survey = new SurveyModel(surveyJson, {
propertyDefaults: {
question: { titleLocation: "left" },
text: { titleLocation: "bottom" }
}
});
- Type:
- IPropertyDefaults readonly
- Implemented in:
- ISurveyOptions
Controls how this survey behaves at runtime.
This object supports the following settings:
Each omitted option uses its current value from the global settings object. For example, the following code set an individual comparator option and inherits the rest:
import { SurveyModel } from "survey-core";
const survey = new SurveyModel(surveyJson, {
runtimeSettings: {
comparator: { caseSensitive: true }
}
});
- Type:
- ISurveyRuntimeSettings readonly
- Implemented in:
- ISurveyOptions
Send feedback to the SurveyJS team
Need help? Visit our support page