html - Knockout checked binding with no default -
I am using knockout to handle interactivity in web applications. I'm trying to create a multi-option quiz widget. I want to present a question, and then a group of radio buttons that the user can choose from the user, I do not want a default answer.
I have the following in my code:
& lt ;! - Aggram: {Data: Answer, as: 'Answer'} - & gt; & Lt; Li class = "list-group-item" & gt; & Lt; Input type = "radio" name = "answer" data-bind = "checked value: answer, checked: $ parent.current.problem.response" & gt; & Lt; Span data-bind = "mathjax: answer.valuext" & gt; 1.5 & lt; / Span & gt; & Lt; / Li & gt; & Lt ;! - / ko - & gt;
Now, the knockout document says:
When the user changes which radio button is selected, then the value of your model's property is equal to the price In the preceding example, the selected radio button will be set, by clicking on the radio button with value = "cherry". Spamflowers should be "cherry"
So, depending on the document, I understand that current.problem.response
must be set to an answer
object . But instead, it's being set to on
.
I think is because my current.problem.response
is viewable initially in null
it's my The domain makes sense for it to be empty if the user has not made any selection.
What should I do?
It seems that your scenario works probably the problem is out of view
var vm = {replies: [text: 'ans1'}, {text: 'ans2'}, {text: 'ans3'}, {text: 'ans4'}], response: Ko.SourceWeb ( tap)}; Vm.answer = vm.answers [0]; Vm.response.subscribe (function (value) {console.log (value);});
According to the model, a small sign correct
Hope this can help if you have any other problems, then specify them in comments.
Comments
Post a Comment