Как отключить переключатель с помощью knockout.js? Я не хочу, чтобы пользователь мог выбрать его. Мой шаблон ниже не работает.
<div id="answers" data-bind="template: { name: 'answerTmpl', data: interactive.answers }">
</div>
<script id="answerTmpl" type="text/html">
{{each(index, value) $data}}
<div>
<input type="radio" value="${index}" name="Answer" data-bind="disable: app.viewModel.avatars.speaking, checked: app.viewModel.interactive.answerSelected"/> <span>${value}</span>
</div>
{{/each}}
</script>
app.avatars.js
(function (app, $, undefined) {
app.viewModel = app.viewModel || {};
app.viewModel.avatars = {
speaking: ko.observable(false),
loaded: ko.observable(false)
};
app.interactive.js
(function (app, $, undefined) {
app.viewModel = app.viewModel || {};
app.viewModel.interactive = {
timeout: 1500,
answers: ko.observableArray(),
answerSelected: ko.observable(''),
correctAnswer: ko.observable(-1),
bookPage: ko.observable(1),
chapterEmail: ko.observable(''),
trialogue: {
inProgress: ko.observable(false),
response: ko.observable(''),
conversation: ko.observableArray()
}
};
app.interactive.init = function () {
ko.applyBindings(app.viewModel);
};