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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:43:00+00:00 2026-06-05T06:43:00+00:00

I’m currently successfully using knockout.js to handle all of my data-binding in my application.

  • 0

I’m currently successfully using knockout.js to handle all of my data-binding in my application. However, on each page load, in my document.ready I’m doing an initial asnychronous data load like this:

$(document).ready() {
  getData()
});

However, is it possible to instead, load the data into a form (using ASP.NET MVC2) and then reverse load the data into the view model based on the data-bind tags?

I feel like this doesn’t work, I just want to confirm that I’m not doing anything improperly.

  • 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-05T06:43:01+00:00Added an answer on June 5, 2026 at 6:43 am

    The ‘value’ binding initially sets the value of the element to the one in your view model, so no. However, you could probably duplicate the code for the ‘value’ binding into your own handler that does initially set the model values from the values on the controls. Download the debug version of knockout, and look for ko.bindingHandlers['value'] = { on line 2182. Copy this binding handler declaration and change ‘value’ to something else, then add a call to valueUpdateHandler() at the end of init:

    ko.bindingHandlers['myvalue'] = {
        'init': function (element, valueAccessor, allBindingsAccessor) {
            // skipping code
            valueUpdateHandler(); // update model with control values
        },
        'update': function (element, valueAccessor) {
            // skipping code
        }
    };
    

    Now when you use the myvalue binding, your model will be updated with the control values when initially bound:

    <input type="text" data-bind="myvalue: name"></input>
    

    Alternatively you could call the original values instead of copying all the code, and just add the code from valueUpdateHandler after the init:

    ko.bindingHandlers['myvalue'] = {
        'init': function (element, valueAccessor, allBindingsAccessor) {
            // call existing value init code
            ko.bindingHandlers['value'].init(element, valueAccessor, allBindingsAccessor);
    
            // valueUpdateHandler() code
            var modelValue = valueAccessor();
            var elementValue = ko.selectExtensions.readValue(element);
            ko.jsonExpressionRewriting.writeValueToProperty(modelValue, allBindingsAccessor, 'value', elementValue, /* checkIfDifferent: */ true);
        },
        'update': function (element, valueAccessor) {
            // call existing value update code
            ko.bindingHandlers['value'].update(element, valueAccessor);
        }
    };
    

    If you don’t want to use AJAX, you can always get the values into javascript by serializing your model as JSON (razor syntax):

    <script type="text/javascript">
    var model = @(new HtmlString(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(Model)));
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I am using parse_ini_file to read the contents of a file however it is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.