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 7920945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:24:08+00:00 2026-06-03T16:24:08+00:00

I have a Knockout.js view model that looks like this: UserName:null, FirstName:null, LastName:null, Countries:{

  • 0

I have a Knockout.js view model that looks like this:

"UserName":null,
"FirstName":null,
"LastName":null,
"Countries":{
    "arrCountries":[]
}

And a set of country checkboxes that all must be rendered with the same data-bind value (I’m using this custom CheckBoxListFor helper, which can apply custom HTML to each checkbox, but it’s the same custom HTML for each checkbox. It takes a property that lists every available country from my razor view model to create the checkboxes, and then renders some as marked based on another razor view model property).

The checkbox values are integers (1, 2, 3, etc) and it’s those integers that I’d like to throw into the arrCountries property of the view model.

Here’s how a checkbox is rendered as it stands at the moment:

<input checked="checked" data_bind="checked: ???" id="Countries.arrCountries107" name="Countries.arrCountries" type="checkbox" value="1"></input>

I’ve proven the concept of using viewModel.Countries.arrCountries.push(1); to update the view model (followed by an alert that gives me a count of the elements in arrCountries to prove that the push worked), but I can’t seem to get the data-bind HTML property on the checkboxes to wire up so that they check and uncheck as I send push and remove commands.

Any help much appreciated!

  • 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-06-03T16:24:09+00:00Added an answer on June 3, 2026 at 4:24 pm

    Make the checked data attribute point to the selected countries. If the checkbox’s value is in the array of checkboxes, then it will be checked. It won’t otherwise.

    <input checked="checked" data-bind="checked: Countries" type="checkbox" value="3"></input>
    

    Take a look at this fiddle I put up.

    http://jsfiddle.net/u8xP9/3/

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

Sidebar

Related Questions

If I have a view model that looks like this when using the knockout
I have an MVC view model that looks like this: public class DirectorySearchModel {
I have a view model something like below, when onAfterRender is fired by Knockout
I have Knockout.js view model that has nested observable arrays. function ParentVM(data) { var
I have a knockout model that is feeding my page and on a save
I have a piece of code working in knockout.js like this: <div> ... some
I have an ASP.NET MVC 3 view using Razor and Knockout.js that is not
I have a Knockout observable array that I wish to edit from within Javascript
I have created a form with knockout that will allow the ability to give
hi i have a model in knockout holded by a variable : var knockoutObject

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.