Note that there are some explanatory texts on larger screens.

plurals
  1. POmore about binding for radio-button checked (somthing that is not disscussed yet)
    text
    copied!<p>Two days ago I asked question <a href="https://stackoverflow.com/questions/19384301/radio-button-checked-binding-html5-durandal">"radio button checked binding html5, durandal"</a>. I accepted an answer that looked well, but it doesn't work.</p> <p>I wanted to only add a comment and tell that it doesn't work; but for adding comment I need 50 reps...</p> <p><strong>If you want to really help me and you don't want to answer me things that will work in your project but not in my project, you must first read my previous questions, so you will know all of the options that I already tried didn't work.</strong></p> <p>So I didn't have another choice but write new question... please don't be angry.</p> <p>I will tell more about my project, may be it will help you to help me... I work in DURANDAL project. I have two radio-buttons, called "searchBy". the first button id is: "byId". the second button id is: "byName". the user have to choose one of them, and I have to know what did he choose.</p> <p>I tried the code that was written in the document that was attached in the comment, it doesn't work.</p> <p>That code below:</p> <p>html code:</p> <pre><code> &lt;tr&gt; &lt;td&gt; &lt;label for="byId" innerHTML:"search by id" /&gt; &lt;input type="radio" name="radSearchBy" id="byId" value="RadioById" data-bind="checked:computedIsId" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;label for="byName" innerHTML:"search by name" /&gt; &lt;input type="radio" name="radSearchBy" value="RadioByName" id="byName" data-bind="checked:computedIsId" /&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>javascript behind:</p> <pre><code> computedIsId:ko.observable("searchById"), </code></pre> <p>it does not work!!!</p> <hr> <p>I tried the code that was written in the first answer, It doesn't either...</p> <p>javascript behind:</p> <pre><code> radSearchBy = ko.observable(true); value = ko.computed({ read: function() { return radSearchBy.toString(); }, write: function(val) { radSearchBy(val === 'true'); } }); </code></pre> <p>html code:</p> <pre><code> &lt;tr&gt; &lt;td&gt; &lt;label for="byId" innerHTML:"search by id" /&gt; &lt;input type="radio" name="radSearchBy" id="byId" data-bind="value" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;label for="byName" innerHTML:"search by name" /&gt; &lt;input type="radio" name="radSearchBy" data-bind="value" id="byName" /&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>I tried also to write in the second button "databind="checked:!value()"", or write else in the first button "()" after the word "value"... nothing help.</p> <p>can you help me?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload