Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

JS Question Type Object

The question type object provides callback functions for the various events that happen while a user configures a product.

Create the file [customization_assets_dir]/javascript/custom_questions.js. CB will automatically load this file if present (or a min.js file if present).

...

  • init() - will run on page load and the function needs to initialise any JS-powered content in the question 

  • initEach() - will run on page load AND each time the configurator view gets refreshed via AJAX calls

  • onSystemSelectionChange(event, questionId, selection) - runs when the system changes a selection (auto-selects, selection removals from rule engine, etc). If the variable selection of is null, it means deselection.

  • onQuestionActivation(event, questionId) - runs when the rule engine activates the question

  • onQuestionDeactivation(event, questionId) - runs when the rule engine deactivates the question

  • onAnswerActivation(event, questionId, answerId) - runs when the rule engine activates an answer of the question

  • onAnswerDeactivation(event, questionId, answerId) - runs when the rule engine deactivates an answer of the question

  • onValidationChange(event, questionId, validation) - runs when the validation engine alters validation settings for the question (calculation based min/max values)

  • onValidationMessageShown(event, questionId, message) - runs when the engine instructs to show a validation message for the question

  • onValidationMessageCleared(event, questionId) - runs when the engine instructs to hide a validation message for the question

...