Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onProgressText event #2370

Closed
andrewtelnov opened this issue Sep 8, 2020 · 0 comments
Closed

Add onProgressText event #2370

andrewtelnov opened this issue Sep 8, 2020 · 0 comments
Milestone

Comments

@andrewtelnov
Copy link
Member

Allow developers to set any text into progress bar.

  /**
   * Use this event to change the progress text in code.
   * <br/> `sender` - the survey object that fires the event.
   * <br/> `options.text` - a progress text, that SurveyJS will render in progress bar.
   * <br/> `options.questionCount` - a number of questions that have input(s). We do not count html or expression questions
   * <br/> `options.answeredQuestionCount` - a number of questions that have input(s) and an user has answered.
   *  @see progressBarType
   */
  public onProgressText: Event<
    (sender: SurveyModel, options: any) => any,
    any
  > = new Event<(sender: SurveyModel, options: any) => any, any>();

Example of showing % of answered questions:

  survey.onProgressText.add((sender: SurveyModel, options: any) => {
    questionCount = options.questionCount;
    answeredQuestionCount = options.answeredQuestionCount;
    options.text =
      "Answered: " +
      (100 * options.answeredQuestionCount) / options.questionCount +
      "%";
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant