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 onValueChanged function for component #2575

Closed
andrewtelnov opened this issue Dec 15, 2020 · 0 comments
Closed

Add onValueChanged function for component #2575

andrewtelnov opened this issue Dec 15, 2020 · 0 comments
Milestone

Comments

@andrewtelnov
Copy link
Member

onValueChanged function will allow to avoid using question.valueChangedCallback callback. Here is the small example:

Survey.ComponentCollection.Instance.add({
    name: "dropdown_and_text",
    elementsJSON: [
      {
        type: "dropdown",
        name: "combo",
        choices: ["A", "B", "C"],
      },
      { type: "text", name: "text1" },
      { type: "text", name: "text2" },
    ],
    onValueChanged: (question, name, value) => {
     //If combo is changed, then set a double value of "combo" to "text1" and clear "text2"
      if (name == "combo") {
        question.setValue("text1", value + value);
        question.setValue("text2", null);
      }
    },
  });
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