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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:37:23+00:00 2026-06-10T08:37:23+00:00

I have a Knockout object mapped from a JSON object. A value of that

  • 0

I have a Knockout object mapped from a JSON object. A value of that knockout object is databound to an input element.

I have also bound a google places autocomplete to that same input element.

The value referenced by the knockout object tells me the value of what I have typed in (not selected, so it would be ‘bar’).

The value of the input box is the correct value (the location I have chosen, ‘Barnet, United Kingdom’).

Here is a JSFiddle that demonstrates the problem…
http://jsfiddle.net/twistedinferno/CPEMk/

Why do the two values differ and can I get the selected value as my bound value? (preferably without the need of another property on my KO object)

  • 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-10T08:37:24+00:00Added an answer on June 10, 2026 at 8:37 am

    Updated JSFiddle here

    This is normal behavior. Knockout registers its value bindings to events it is aware of such as afterkeypress or blur. It cannot ‘detect’ changes made by other frameworks such Google Places API by default. So, in order to work, you need to write some code that pushes events from the other framework to Knockout.

    In this case, Google Places Autocomplete API supports a place_changed event. I’ve incorporated this event in my updated Fiddle to showcase a working example. See the Google documentation for more information about this event. The most important bit is:

    google.maps.event.addListener(autocomplete, 'place_changed', function() {
        var place = autocomplete.getPlace();
        koObj.StartDescription(place.formatted_address);
        koObj.Name(place.name);
        koObj.Address(place.formatted_address);
    });
    

    However, if you intend to use this functionality more than once, I strongly suggest you wrap this behavior in a custom Knockout binding.

    Here’s an excellent article about custom Knockout bindings. If you scroll all the way down to the last chapter, you will see an example of a Knockout binding that wraps around a third party control. You will want to do the same for Google Places Autocomplete, so you can handle three aspects of working with this control:

    1. Initializing the control (with optional config options for the widget)
    2. Responding to updates made in the UI by setting up an event handler. This is achieved by wrapping around the place_changed event.
    3. Responding to updates made to the view model. This might not be necessary for your scenario.

    Using a custom knockout binding will look something like this:

    <input id="startDescription" type="text" data-bind="googleAutoComplete: StartDescription, googleAutoCompleteOptions: { componentRestrictions: { country: 'uk' } }" />
    

    Good luck!

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

Sidebar

Related Questions

I have a Knockout observable array that I wish to edit from within Javascript
I have a Knockout Viewmodel that uses the mapping plugin. After mapping the JSON
I have a knockout model that is feeding my page and on a save
I have created a form with knockout that will allow the ability to give
I have the following table template that is rendered through knockout: <table class=gv data-bind=visible:
I have a page that requires jQuery.tmpl, but I want to use native knockout
Suppose I have knockout.js template like this: <script type=text/html id=mytemplate> <label for=inputId>Label for input</label>
I have an issue with Knockout where I prototype a user object where the
In my JS I have the following ajax call, that bind the resulting json
I'm using Knockout with jQuery and jQuery templates. Assume that I have a template

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.