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);
Methods
Events
events property

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 the events object instead if you need to handle events raised during that load.

Type:
SurveyEventHandlers readonly
Implemented in:
ISurveyOptions
propertyDefaults property

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
runtimeSettings property

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

Your cookie settings

We use cookies to make your browsing experience more convenient and personal. Some cookies are essential, while others help us analyse traffic. Your personal data and cookies may be used for ad personalization. By clicking “Accept All”, you consent to the use of all cookies as described in our Terms of Use and Privacy Statement. You can manage your preferences in “Cookie settings.”

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.