Skip to content

Commit 7f45f5d

Browse files
hjdivadcyril-sf
authored andcommitted
Tutorial: Send grade events.
1 parent cf3ff16 commit 7f45f5d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

example/cards/tutorial/survey_card.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ var gradingTemplate = '<div><form>{{#each grades}}<input type="radio" name="surv
77
var gradeResultTemplate = '<div>Your rating: {{grade}} <button id="changeGrade">Change</button></div>';
88

99
Conductor.card({
10+
consumers: { survey: Conductor.Oasis.Consumer },
11+
1012
grade: null,
1113
grades: ["A", "B", "C", "D", "F"],
1214
renderMode: 'survey',
@@ -55,6 +57,13 @@ Conductor.card({
5557
var grade = $('input:radio[name=survey]:checked').val();
5658
if (grade) {
5759
$(this).off('click');
60+
if (card.consumers.survey) {
61+
if (!card.grade) {
62+
card.consumers.survey.send('surveyTaken', grade);
63+
} else {
64+
card.consumers.survey.send('gradeChanged', grade);
65+
}
66+
}
5867
card.grade = grade;
5968
card.renderReport();
6069
}

0 commit comments

Comments
 (0)