Knockout Js radio binding not setting value


Callum Linington

Here's the documentation I'm looking at: Example of adding a radio button

it says:

And only if the parameter value is equal to the value attribute of the radio button node, KO will set the element to check

What I did here: jsfiddle

self.radioValue = ko.observable(1);

Japanese HTML:

<input type="radio" name="teloremail" value="1" data-bind="checked: radioValue" />

For me this doesn't automatically set the radio tochecked

Is there any reason?

nemesv

The radio button node's valueproperty is of type string, so you also need to store the value stringin the observable:

self.radioValue = ko.observable("1");

Demo JSFiddle .

The example also uses the string: "almond".

Related


Knockout Js radio binding not setting value

Callum Linington Here's the documentation I'm looking at: Example of adding a radio button it says: And only if the parameter value is equal to the value attribute of the radio button node, KO will set the element to check What I did here: jsfiddle self.radioV

Knockout.js - "value" binding in "html" binding

thread lemon I'm working on an application that needs to generate HTML dynamically based on some values. I put the following code where the dynamic HTML is: <div data-bind="html: extraHTML"></div> I have an object setup in my javascript file that contains var

Knockout.js - "value" binding in "html" binding

thread lemon I'm working on an application that needs to generate HTML dynamically based on some values. I put the following code where the dynamic HTML is: <div data-bind="html: extraHTML"></div> I have an object setup in my javascript file that contains var

About data binding by knockout js and value change

Thomas There are two textboxes and a span bound by culling. The example I got is easy to understand. Here is the code. <p>First name: <input data-bind="value: firstName" /></p> <p>Last name: <input data-bind="value: lastName" /></p> <h2>Hello, <span data-bind=

About data binding by knockout js and value change

Thomas There are two textboxes and a span bound by culling. The example I got is easy to understand. Here is the code. <p>First name: <input data-bind="value: firstName" /></p> <p>Last name: <input data-bind="value: lastName" /></p> <h2>Hello, <span data-bind=

About data binding by knockout js and value change

Thomas There are two textboxes and a span bound by culling. The example I got is easy to understand. Here is the code. <p>First name: <input data-bind="value: firstName" /></p> <p>Last name: <input data-bind="value: lastName" /></p> <h2>Hello, <span data-bind=

Knockout radio button binding with boolean

Dhanuka 777 Based on this fiddle I created at runtime , it doesn't bind the value to the "no Blue" option as expected. var viewModel = { isBlue: ko.observable(false) //isBlue: ko.observable("false") this works }; As I mentioned in it, when I pass

Constrained knockout value binding

Wei Ma I am using a knockout table to implement a shopping cart. One of the requirements is to allow customers to change the quantity of items. So naturally I will <input type="text" data-bind="value: quantity"/> In my view mode I have an item ViewModel defin

In knockout js, radio button's observable value is not changed

Srinivas Naidu I have an object Address. In the address there are fields like street, country, state, IsDefault. The address can be multiple, IsDefault will be the radio button. $.each(self.Addresses(), function (index, address) { address.Street =

How to get value of radio button option in Knockout.js wizard?

Albatross Cafe For simplicity, here is the fiddle : http://jsfiddle.net/FyuSD/157/ <script id="choiceTmpl" type="text/html"> <label><input type="radio" value="boughtBefore" data-bind="checked: radioSelectedOptionValue" />Purchase products I have bo

In knockout js, radio button's observable value is not changed

Srinivas Naidu I have an object Address. In the address there are fields like street, country, state, IsDefault. The address can be multiple, IsDefault will be the radio button. $.each(self.Addresses(), function (index, address) { address.Street =

How to get value of radio button option in Knockout.js wizard?

Albatross Cafe For simplicity, here is the fiddle : http://jsfiddle.net/FyuSD/157/ <script id="choiceTmpl" type="text/html"> <label><input type="radio" value="boughtBefore" data-bind="checked: radioSelectedOptionValue" />Purchase products I have bo

Knockout js CSS binding

kitten salvaji I am using Knockout js in my project and I need to add multiple css class names to specific tags. Below is my code, I have three different classes, how can I add it to the knockout css binding, kindly suggest. <img data-bind="attr: { src:Profile

knockout js check binding

username I'm new to knockout and also a little confused about checkbox bindings. I have the following HTML: <input id="Category-2039842085241261997" type="checkbox" value="203984,208524,1261997" data-bind="checked:toggleActivation"> <label for="Category-2039

Knockout js binding not updating

User 135498 I have a view model that contains a reference to another object, and the referenced object is bound to my UI. When I add objects to the observable array, the bindings seem to work fine, but when I clear the array, the bindings don't seem to update.

Knockout js binding not updating

User 135498 I have a view model that contains a reference to another object, and that referenced object is bound to my UI. When I add objects to the observable array, the bindings seem to work fine, but when I clear the array, the bindings don't seem to update

knockout js check binding

username I'm new to knockout and also a little confused about checkbox bindings. I have the following HTML: <input id="Category-2039842085241261997" type="checkbox" value="203984,208524,1261997" data-bind="checked:toggleActivation"> <label for="Category-2039

Knockout js binding not updating

User 135498 I have a view model that contains a reference to another object, and that referenced object is bound to my UI. When I add objects to the observable array, the bindings seem to work fine, but when I clear the array, the bindings don't seem to update

Binding knockout updates in .js

Mike W This is most likely a very basic question for anyone familiar with ockout.js, but it's causing me problems. The situation I'm having is that I have a model that contains an array of items that are dynamically added to and displayed in a view. So far, no

Knockout.js data binding hidden field value

Veda Shurab I have a hidden field in a knockout template whose value is updated using jquery. The problem is that when trying to pass this value to the server using ajax, I get a null value in the controller. But the html source shows that the value of the hid

How to apply binding and persist input value using Knockout JS?

Kees C. Bakker I am building an HTML/KnockoutJS application. My web server returns a form with input fields and information. When I update the model and execute ko.applyBindings, the input value is naturally overwritten by the model. Is there a way to automati

Knockout.js data binding hidden field value

Veda Shurab I have a hidden field in a knockout template whose value is updated using jquery. The problem is that when trying to pass this value to the server using ajax, I get a null value in the controller. But the html source shows that the value of the hid

How to apply binding and persist input value using Knockout JS?

Kees C. Bakker I am building an HTML/KnockoutJS application. My web server returns a form with input fields and information. When I update the model and execute ko.applyBindings, the input value is naturally overwritten by the model. Is there a way to automati

How to apply binding and persist input value using Knockout JS?

Kees C. Bakker I am building an HTML/KnockoutJS application. My web server returns a form with input fields and information. When I update the model and execute ko.applyBindings, the input value is naturally overwritten by the model. Is there a way to automati