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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:28:46+00:00 2026-06-13T01:28:46+00:00

This jsFiddle displays the incorrect code for my objective. I’d like every time the

  • 0

This jsFiddle displays the incorrect code for my objective. I’d like every time the user selects a Day for that day to be added/removed to the byday list. Using Knockout 2.1.0.

HTML:

<ul data-bind="foreach: bydayOptions">
    <li>
        <input type="checkbox" name="byday" data-bind="attr: {value: value, checked: $parent.byday().indexOf(value) >= 0}, event: {change: $parent.bydayHandler(value)}">
        <label data-bind="for: value"><b data-bind="text: $data.text"></b></label>
    </li>
</ul>

<b data-bind="text: ko.toJSON(byday())"></b>
​

JavaScript:

var viewModel = function(args) {
    var self = this;
    self.byday = ko.observableArray(args.byday);

    self.bydayOptions = [{
        text: "Monday",
        value: "Mon"
    }, {text: "Tuesday",
        value: "Tue"
    }, {text: "Wednesday",
        value: "Wed",
    }, {text: "Thursday",
        value: "Thu"
    }, {text: "Friday",
        value: "Fri"
    }, {text: "Saturday",
        value: "Sat"
    }, {text: "Sunday",
        value: "Sun"
    }];

    self.bydayHandler = function(d){
        console.debug(">>> inside the byday Handler");
        console.log(self.byday());
        if(d !== undefined){
            if(self.byday().indexOf(d) >= 0){
                self.byday().splice(self.byday().indexOf(d), 1);
            } else {
                self.byday().push(d);
            }
        }
    };
};

ko.applyBindings(new viewModel({byday: ["Mon"]}));

​

  • 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-13T01:28:48+00:00Added an answer on June 13, 2026 at 1:28 am

    The knockout checked binding takes care of a lot of this for you. There’s no need for an event handler.

    Here’s a updated fiddle:
    http://jsfiddle.net/daedalus28/pmMZW/

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

Sidebar

Related Questions

I have an unordered list that displays like this: http://jsfiddle.net/spryno724/XYBja/ . Notice how the
I have this code below where the problem is that it displays the <span>
In here, http://jsfiddle.net/sjKgF/78/ JS CODE $('.display_box').hover(function (){ $(this).attr('class', 'display_box current') }, function (){ $(this).attr('class',
Currently I have a stacked bar chart like this ( jsfiddle demo ) I
I have this code here http://jsfiddle.net/RzBeM/65/ you will see two input fields called quantity.
Hopefully I can explain this clearly enough. I have a table that displays some
I have a JSFiddle up and running that displays what I'm trying to accomplish:
I am trying to achieve this: http://jsfiddle.net/BcFVv/2/ This is my local code, but it's
Some background: I have a site header and created some jQuery code that displays
I made up this jsfiddle, which displays correctly in all browsers except ie (testing

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.