Я пытаюсь создать собственный мастер форм, который будет содержать различные шаги автоформирования в зависимости от определенных условий. Упрощенный пример meteorPad приведен ниже. Когда реактивный источник данных (переменная сеанса) изменяется, запускается реактивное вычисление (помощник шаблона), что подтверждается выводом консоли. Однако шаблон не обновляется и по-прежнему содержит то же количество шагов. Есть ли что-то, что мне нужно сделать, чтобы правильно обновить шаблон? Спасибо! http://meteorpad.com/pad/cPWShRiTKYpBaMahn/Leaderboard
html
<body>
{{> basicWizard}}
{{> changeSteps}}
</body>
<template name="basicWizard">
<!--shouldn't the steps variable update when the helper runs?-->
{{> wizard id="basic-wizard" steps=steps}}
</template>
<template name="changeSteps">
<button id="changeStepsButton"> change number of Steps </button>
</template>
клиентский код
Session.set('twoSteps', false);
information = new SimpleSchema({
password: {
type: String,
label: 'password',
},
});
confirm = new SimpleSchema({
userName: {
type: String,
label: 'blah',
},
});
Template.basicWizard.helpers({
steps: function() {
var ret = [];
if (Session.get("twoSteps")) {
ret[ret.length] =
{
id: 'information',
title: 'Information',
schema: information,
}
}
ret[ret.length] =
{
id: 'confirm',
title: 'Confirm',
schema: confirm ,
}
console.log("num steps: " + ret.length)
return ret;
}
});
Template.changeSteps.events({
"click #changeStepsButton": function (event) {
Session.set('twoSteps', !Session.get("twoSteps"));
},
})