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

  • Home
  • SEARCH
  • 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 8079377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:04:54+00:00 2026-06-05T16:04:54+00:00

I am trying to bind a model coming from the server over json to

  • 0

I am trying to bind a model coming from the server over json to a viewmodel I create on the client and then bind it using Knockout.js to display the data. I have the following code

function tireRunDataViewModel() {
        var self = this;

        self.load = function() {
            $.jQuery.post('./GetTireRunModel', { outingID: '@Model' }, function (result) {
                self.data = ko.mapping.fromJS(result);
            } , "json");
        };

        self.load();
    }

var viewModel = new tireRunDataViewModel();
ko.applyBindings(viewModel);

It appears as though self.data is not being set before the ko.applyBindings is being done. Why is this and what can I do to make sure the self.data is being filled out before the applyBindings is being done?

  • 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-05T16:04:56+00:00Added an answer on June 5, 2026 at 4:04 pm

    The call to $.jQuery.post is asynchronous, so the callback does not execute until it completes, which is after ko.applyBindings is called.

    A couple of options:

    • you could call ko.applyBindings in your callback. If your application is not more complicated than this, then it can be an option to apply bindings after the AJAX call has completed.

    • you could create self.data as an observable and then updated it in the callback like: self.data(ko.mapping.fromJS(result));. Then in your UI you could use a with binding on data around the UI that depends on data, so that it is not rendered until it is ready.

    Quick simulation of it: http://jsfiddle.net/rniemeyer/Wf8E8/

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

Sidebar

Related Questions

I am trying to bind model received from Ajax call but that do not
Using MVC3 and Entity Framework. Am trying to get validation flowing from data model
I'm kind of new to backbone coming from knockout.js and I'm trying to get
I'm trying to bind columns from two different tables in to gridview using Linq
Having some issues trying to model bind to my view model. The basic viewmodel
I am trying to bind a JSON stringified object to a model and few
I'm trying to model bind a set of dynamically generated checkboxes so as to
I'm trying to bind a view model property to the 'SelectedItem' attribute of a
I'm trying to get a nested model to bind correctly with a nested view
I'm trying to bind two sliders from two separate qooxdoo classes and am looking

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.