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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:40:28+00:00 2026-06-16T10:40:28+00:00

I have a checkbox bound to my KOJS model. <input type=checkbox data-bind=checked:settings.remember> I’m trying

  • 0

I have a checkbox bound to my KOJS model.

<input type="checkbox" data-bind="checked:settings.remember">

I’m trying to update the database when the user changes the value of the checkbox. However, the viewmodel is updated after these jQuery functions:

$("input[type='checkbox']").click(function(){ });

$("input[type='checkbox']").change(function(){ });

$("input[type='checkbox']").mouseup(function(){ });

To put it another way, when I peek into my viewModel inside of those functions, it will return the value of the checkbox’s value before the user had changed it. So if the checkbox was once true and now tells me false (and displays as false), the viewModel will still say true.

Is there some other jQuery function I could use that might occur after the binding occurs? Or can you think of any other clever way to call a function after my viewModel variable has changed? Note that my current viewModel declaration is:

var viewModel = {};
//...get some data from AJAX calls
ko.mapping.fromJSON(data, viewModel.'+file+');

where file is some dynamic value (I draw my viewModel from multiple databases)

I can solve the above problem with a hacky solution below (see my answer), but RP Niemeyer’s answer suggests there is a better way with manual subscriptions. So far I haven’t been able to figure out defining things within my viewModel along with using the mapping plugin.

Here’s my code so far, though, of course, it won’t work on the JSFiddle.

  • 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-16T10:40:29+00:00Added an answer on June 16, 2026 at 10:40 am

    Generally, a good choice for this type of thing is to handle it in your view model itself. For example, you can use a manual subscription against settings.remember (if it is an observable) and trigger your database call.

    settings = {
      remember: ko.observable(false)
    };
    
    settings.remember.subscribe(function(newValue) {
        //run your logic here
    }, settings);
    

    The second argument to the subscribe call determines the value of this when the function runs.

    If you are really forced to interact with your field changing outside of Knockout, then you would want to hook up a “change” handler, but not until after ko.applyBindings has been called. Then your change event handler will run after the change handler that Knockout has already added to the element. However, if your content is in a template and gets re-rendered, then your handler would be lost.

    I would highly recommend using the manual subscription approach.

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

Sidebar

Related Questions

I have a checkbox who's checked value is bound to a binding source which
I have a checkbox column bound to a dependency property. When editing the checked
I have a checkbox bound to an observable on a view model. I have
In my WPF application I have a CheckBox whose IsChecked value is bound to
I have a ListView with a CheckBox as one of the columns, bound to
I have checkBox and Spinner . If the checkbox is checked, then spinner should
I have added checkbox selection model to grid panel. It works fine in IE8
I have an NSOutlineView with checkboxes. I have the checkbox state bound to a
I have a grid view that is data bound to a dataset. In a
I have a few TextBoxes that are bound to a single CheckBox . This

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.