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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:50:59+00:00 2026-06-05T19:50:59+00:00

Ive created a function which returns all the obserables items in my html page.

  • 0

Ive created a function which returns all the obserables items in my html page. An exmaple of this function is

<input type="text" id="frmIn1-Officer" data-bind="value: AOfficer" class="InputText"/>
<input type="text" id="frmIn1-Officer" data-bind="value: AOfficer2" class="InputText"/>
<input type="text" id="frmIn1-Officer" data-bind="value: AOfficer3" class="InputText"/>
<input type="text" id="frmIn1-Officer" data-bind="value: AOfficer4" class="InputText"/>

The function would reutrn [‘AOfficer’,’AOfficer2′,’AOfficer3′,’AOfficer4′]

And now i want to be make the above list of data-bind elemnts obserable

viewModel = {
AOfficer : ko.observable(),
AOfficer2 : ko.observable(),
AOfficer3 : ko.observable(),
AOfficer4 : ko.observable(),
}
ko.applyBindings(viewModel);

Above is the un-dynamic way of doing this.. But i just cant seem to find a dynamic way to solve this problem..

How would i go about solving this? Is there a solution? A work around?

Thanks guys

  • 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-05T19:51:01+00:00Added an answer on June 5, 2026 at 7:51 pm

    One option that I have used in the past is to create a custom binding that will populate the view model for you from the existing value.

    Something like:

    ko.bindingHandlers.valueWithInit = {
        init: function(element, valueAccessor, allBindingsAccessor, data) {
            var property = valueAccessor(),
                value = element.value;
    
            //create the observable, if it doesn't exist 
            if (!ko.isWriteableObservable(data[property])) {
                data[property] = ko.observable();
            }
            data[property](value);
    
            ko.applyBindingsToNode(element, { value: data[property] });
    
        }
    };
    

    When you add the binding, you need to specify the property name as a string, so that the binding does not fail when it does not initially exist.

    This method will create an observable for you, if it does not exist or simply populate an existing observable with the element’s value.

    Sample here: http://jsfiddle.net/rniemeyer/BnDh6/

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

Sidebar

Related Questions

I ve created function and trigger as follows: CREATE OR REPLACE FUNCTION New_Ticket() RETURNS
I've created this function to read a word. I got segmentation fault and I
I'm trying to solve this newbie puzzle: I've created this function: def bucket_loop(htable, key):
I've created a javascript function that will take a hidden span, copy the text
I've created a function to overlay text onto images, but I'm scratching my head
I'm using MVC and I've created a HtmlHelper extension function ImageLink. This function uses
I've embedded Python in my C++ application, and I've created several C functions which
I've created regular function. It has been created successfully. But when I run it
I'm using C structs in objc and I've created a function that assembles the
I've created a wrapper function for jQuery's $.ajax() method so I can pass different

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.