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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:59:52+00:00 2026-06-01T01:59:52+00:00

I feel like this must have been asked before, but I’ve looked at Knockout

  • 0

I feel like this must have been asked before, but I’ve looked at

  • Knockout JS binding initial value of dropdown list
  • Knockout does not sync manual set of option’s selected attribute
  • How to pre-select an option in a dropdown knockout js

and

  • How to set initial values for Knockout’s observables (for cascading lists)?

But those problems weren’t quite the one I’m facing.

In my view I receive a viewmodel from an ajax call. In that object is a country ID. In a subsequent ajax call, I retrieve a list of countries (name and ID) and populate a select box from the list.

The select box is bound to the viewmodel’s country ID using

<select data-bind="value: CountryId"/>

But when I populate the dropdown, the viewmodel’s country is not pre-selected. I have to manually call ko.applyBindings(vm), which is a problem because the data is populated from a jQuery plugin that handles cascaded select boxes. It doesn’t have references to the viewmodel (nor do I want to provide it). I could expose a callback, but that’s a bit yawn.

I have created a fiddle that illustrates this problem more cleanly. If you click on the Test Select button, you will notice that the dropdown is preselected to Item 0. Uncomment the line in the js panel, and Bob’s your uncle.

What am I not getting here? Isn’t this a basic knockout feature?

-Jules

  • 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-01T01:59:54+00:00Added an answer on June 1, 2026 at 1:59 am

    So as John Earles said, adding items to the select list doesn’t trigger a ‘change’ event. I have concluded that’s actually a Good Thing. From one of the (really good) Knockout tutes:

    Bindings catch DOM events and correspondingly update viewmodel properties.

    That’s the reverse behaviour from what I want! So I’ve stuck with the callback. At present it just calls applyBindings(). You can see an example in this revision of the original fiddle (callbacks etc omitted for clarity).

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

Sidebar

Related Questions

I feel like this must have been asked, but I'm unable to find it
I feel like this must be very simple, but for some reason I am
I feel like I must have missed the right thread, because this seems like
I feel like this must be simple to do but can't get it done
I feel like a bit of a newbie posting this, but anyway: I have
I feel like this is something I should already know, but I'm just not
I feel like this is easy but I am missing something... Using jQuery, I
I feel like this should be a no brainer, but clearly I'm missing something...
I feel like this is a stupid question, but I can't think of a
I feel like this should be obvious to me, but for some reason I

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.