Radio button not checked after click

I'm trying bind a click event to a radio button using Knockout. However, when the radio button is clicked, it's not saved.

Right now, I'm just returning true from the event. I can see that the event is indeed called. If I try to console.log($parent.SelectedCrossing()) the value is saved. Any ideas?

My markup:

<div class="row"> <!-- ko foreach: SelectedRoutes --> <div class="jumbotron text-center"> <table class="table table-hover borderless" data-bind="visible: availableRoutes().length"> <tbody> <!-- ko foreach: availableRoutes --> <tr> <td> <input type="radio" data-bind="attr: { value: ID() + bkt(), name: $parentContext.$index() + 'optionsRoute', disabled: !IsBookable }, checked: $parent.SelectedCrossing, click: function () { $parents[1].AvailableRouteChosen($parents[0]) }" /> </td> <td> <span data-bind="dateTime: TimeOfDeparture"></span> </td> <td> <span data-bind="dateTime: TimeOfArrival"></span> </td> </tr> <!-- /ko --> </tbody> </table> </div> <!-- /ko --> </div>

The js:

self.AvailableRouteChosen = function (obj) { return true; }

-------------Problems Reply------------

your click handler isn't returning anything:

click: function () { $parents[1].AvailableRouteChosen($parents[0]) }

although your underlying function is (and is returning true, which you need to do to override the default click behavior). just return the result:

click: function () { return $parents[1].AvailableRouteChosen($parents[0]) }

Category:knockout.js Views:1 Time:2019-01-11
Tags: knockout.js

Related post

  • IE - hidden radio button not checked when the corresponding label is clicked 2009-08-10

    I just noticed a strange behaviour in IE7. I have radio buttons with associated labels as follows: <input type="radio" name="filter" id="filter_1" value="Activities" checked="checked" /> <label for="filter_1">Activities</label> <

  • Check is a radio button is checked after post back in ASP.NET 2010-12-13

    I am looping through all the posted data on my website and grabbing the values, this will then be used later on. The user is going to put 2 radio buttons on the page, one with a correct answer and one with an incorrect answer. I need to know how to s

  • radio buttons not checked in UI but checked in HTML in Partial View 2015-09-18

    I am having a partial view which has textbox, drop-down-list and readio buttons. I have to load this partial view on a view in a for loop. textbox and drop-down controls in the partial view are getting populated properly but radio-buttons are not. Wh

  • Dynamically added radio button not updated when clicked in IE6, IE7 2010-12-13

    I have added a group of radio buttons dynamically to the DOM using jQuery. I have registered event handlers, which work well. However, when clicked in IE6 and IE7, the radio button group is not updated with which button is checked. My original code i

  • How to change number values in PHP when radio button is check or click 2011-08-03

    I have 4 rows in a table. Each row has 4 radio buttons. Each radio buttons has value number [1, 2, 3, 4] When user selects one of the radio buttons, it automatically prints the value in each row. Then I take each value and total them at the bottom of

  • Javascript: Radio button not checked value 2011-10-02

    I have variable that get's value of checked radio button named: parentcheck I wanna check if parentcheck is checked and =0 or if not checked. Tried if(parentcheck=='') for "not checked". it doesn't work. var parentcheck = $(".parentcheck:checked").va

  • Radio buttons not checked in jQuery 2008-12-16

    I have this line of code for page load: if ($("input").is(':checked')) { and it works fine when the radio button input is checked. However, I want the opposite. Something along the lines of if ($("input").not(.is(':checked'))) { so that my if stateme

  • AngularJS radio buttons not checked on load 2015-02-11

    I have an angularJS controller that creates a scope with a list of items and has a property for the selected item. During initialization I create the list and set the selectedItem property to the second item in the list. app.controller('MainCtrl', fu

  • How do I preserve radio button and check box value without using cookies after the browser refresh? 2009-07-19

    I have three radio buttons and 4 check boxes. I want to preserve the radio button and check box values after the browser refresh. I do not want to use cookies (due to some other reason). Could anyone please help me? --------------Solutions-----------

  • How not to submit a form if no radio button is checked 2011-07-21

    I using PHP in order to create an HTML form. The form has 3 radio buttons and a submit button. In the initial state of the form, none of the radio buttons is checked. I want to make the form not to be submitted if non of the radio buttons is checked.

  • Android - Change LinearLayout visibility automatically after radio button is checked 2011-12-22

    Currently, my linearlayout is set as GONE in my main.xml. I need to set the visibility of my linearlayout to visibile automatically once a radio button is checked. But having error force close. Is there anything wrong with my codes? calc.java public

  • How to use jQuery to show content based on whether radio button is checked 2009-12-22

    I'm stuck on something. I have a form that has fields which only show when a particular radio button is checked. This is easy enough to when someone is filling out the form for the first time using the following code. HTML <fieldset id="question"

  • Find out if radio button is checked with JQuery? 2010-02-16

    I can set a radio button to checked fine, but what I want to do is setup a sort of 'listener' that activates when a certain radio button is checked. Take, for example the following code: $("#element").click(function() { $('#radio_button').attr("check

  • Using jQuery to check if some radio buttons are checked and apply CSS block style 2010-02-17

    I'm trying to check if one of the following radio buttons is selected and am beginning to think that there must be a better way of achieving the same result using a different jQuery approach. E.g: if($("input[id='incRating_yes']:checked").val()) $('.

  • How to check the user selections on dynamically generated radio buttons and check boxes in Flex? 2011-01-27

    The following is my codes. This is still work in progress; so, you will see some functions with empty contents. Plus, this is my first Flex application; please bear with me. This is a quiz application that gets the questions and answers to each quest

  • Toggle DIV when Radio Buttons are checked 2011-04-12

    I am trying to make a DIV toggle visible and not visible when a group of radio buttons say yes or no. For example I have a a list of stores in a DIV but I only want that list of stores visible when the radio button is checked as yes. Edit Script View

  • Greying out certain parts of html until a radio button is checked 2011-04-12

    I have a weird request i havent had before and im not sure how to go about it. Basically i have an online application form, each question is contained in its own div, at first i want the first div shown and the rest of the questions to be 'greyed' ou

  • Jquery: If statement help, if (radio button is checked) then Jquery, else 2011-05-08

    I have this JQuery Code, Its in the DOM Ready, on click of .deleteCatFavs it runs this function. I want to add some If functionality to this but am having trouble. // Delete a Favorite Category, $('.deleteCatFavs').live("click", function(){ var actio

  • Initialize radio button as checked 2011-06-05

    I am having trouble initializing a radio button as checked. What I mean is when I open the form, none of my 2 radio buttons are checked, but they work fine after I check on of them. I tried setting one of them as checked in the Form constructor, but

  • How to detect if a certain radio button is checked with jQuery? 2011-06-07

    I'm using the jQuery Validate plug-in and need to require a field if a certain radio button is checked. How can I determine if a certain country is selected? For example, if the Canada radio button is checked, then require this field. This isn't righ

  • How do I get the form up if the radio button is checked? (AJAX) 2011-07-04

    I am facing problems while writing a program that has 3 radio buttons, each radio button, when checked, should display a small form on the part of the same webpage. I am using AJAX and PHP. My question is, how do I write the function to display the c

  • Jquery If radio button is checked 2011-07-11

    Possible Duplicate: Check of specific radio button is checked I have these 2 radio buttons at the moment so that the user can decide whether they need postage included in the price or not: <input type="radio" id="postageyes" name="postage" value="

  • how to call a javascript function on radio button's 'checked' property? 2011-11-18

    I have N number of radio button groups in the page with auto generated names. I want to call a javascript function as the value of the checked property. THIS LINE EXCLUDED AFTER EDIT ( Depending on the return value, the radio button needs to be check

  • jQuery Custom Radio Buttons not working as radio buttons 2012-01-12

    I am using JQuery and custom images for custom radio buttons. Right now, it would work as a checkbox. I need it to work as a radio. When I click on either of both radio's both will get ticked instead of one at a time. Am I missing something? HTML:

  • Radio button not working to highlight email (Outlook) for deletion? 2012-03-24

    Is there an issue with the radio button on Outlook, not able to check on the box to highlight the email for deletion. Advise please. --------------Solutions------------- Hello, We're sorry to to hear that you're having a problem with the radio button

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.091 (s). 11 q(s)