Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6943751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:11:50+00:00 2026-05-27T13:11:50+00:00

I am having trouble with the checked binding: clicking on the checkbox doesn’t update

  • 0

I am having trouble with the checked binding: clicking on the checkbox doesn’t update the visible status, although a dependentObservable indicates that the value has changed.

Here is the HTML fragment:

<input type="checkbox" 
        data-bind="checked: document().selected" 
        title="Select one or more documents to find more similar ones" >

This is bound to an instance of my Posting class that has a document() observable. The relevant part of the document class looks like this:

function Document(data, topic) {
    this.id = ko.observable(data.id);
    this.url = ko.observable(data.url);
    this.title = ko.observable(data.title);

    /** Display state **/
    this.selected = ko.observable(false);
    ko.dependentObservable(function() {
        console.log("Selected " + this.url() + " : " + this.selected());
    }, this);

}

When I click on the check box, the console prints something like this:

Selected http://somedomain.com/doc1.pdf : true

and yet the checkbox remains unchecked.

I am using jQuery 1.4.2 and knockout 1.2.1

Other aspects of knockout seem to be working correctly. When I isolated the problem in jsffiddle like this, it worked as expected. Any thoughts on what I should test next?

Gene

UPDATE: Dec 12, 2011 2:54 PST:

@RP Niemeyer: I have many other dependentObservable instances; the only one that metnions selected() looks like this:

this.selectedDocuments = ko.dependentObservable( function() {
    return this.documents().findAll(function(doc) {return doc.selected()});
}, this);

findAll does what you mighht think.

As far as I can tell, what’s happening is that the selected observable is set to true when the checkbox is triggered, which fires the dependentObservable, which prints the correct value. The view is not updated, however. Nonetheless, the observable thinks it’s set to true, because subsequent clicks on the same (deselected) checkbox do not produce any further console output.

UPDATE Dec 12, 2011, 9:45 PM PST:

I was able to reproduce the problem in this jsfiddle. If you edit out the click handler on the enclosing div, the checkboxes work correctly. Is there a work-around, or is this a known problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:11:51+00:00Added an answer on May 27, 2026 at 1:11 pm

    OK- with the updates it makes sense. What you can do is return true; from the click handler that is on the outside div. This will allow the default action to proceed.

    http://jsfiddle.net/rniemeyer/SbuEV/8/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having trouble receiving a list of items that are checked in a field
Having trouble with checkboxes that are being pre-checked (when fetching record from mysql). So
Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that
I'm having some trouble on a checked out project here at work. I have
I'm having trouble finding out which tag is currently checked out. When I do:
Having trouble getting my POST arrays to show all checkbox values from my form.
I'm having trouble passing a variable in the following var whichRbClicked = $('input:radio[name=RBname]:checked').val(); where
I'm having trouble setting up Teamcity and Git. I have a git repo checked
I'm having trouble with a liferay installation that is suddenly (without any code modifications)
I'm having trouble getting a simple dependentObservable chain to work in knockout.js. Here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.