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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:38:52+00:00 2026-05-31T11:38:52+00:00

I got couple question with the following code Does the TokenList in PromoTemplate a

  • 0

I got couple question with the following code

  1. Does the TokenList in PromoTemplate a observableArray, what happened to each item in the array ? are they automatically gets wrapped into observable?

  2. All the binding seems to work, i am be able to get all the way down to a Token’s value, but when I modify the data in a input it doesn’t seem to notify other controls that are bound to the same property, for example the AttributeToken.Value.

    function AttributeToken(data) {
        this.Identifier = ko.observable(data.Identifier)
        this.DataType = ko.observable(data.DataType)
        this.Value = ko.observable(data.Value);
    }
    
    function PromoTemplate(data) {
        this.Identifier = ko.observable(data.Identifier);
        this.Name = ko.observable(data.Name);
        this.Content = ko.observable(data.Content);
        this.TokenList = ko.observableArray(data.Tokens);
        this.Sample;
    }
    
    function PromoTemplateViewModel() {
        // Data
        var self = this;
        self.promoTemplates = ko.observableArray([]);
    
    
        self.selectedPromoTemplate = ko.observable();
    
        // Init
        $.getJSON(promoTemplatesUrl, function (allData) {
            var mappedPromoTemplates = $.map(allData, function (item) { return new PromoTemplate(item) });
            self.promoTemplates(mappedPromoTemplates);
        });
    
    }
    

the json data look like the following

[{"Content":"<product><data price = \"100\" discountPercentage=\"{Percentage}\" startDate=\"{StartDate}\" ><\/data><\/product>","Description":null,"Identifier":"1","Name":"Percentage Promo","Tokens":[{"DataType":"double","Identifier":"{Percentage}","Value":"20"},{"DataType":"date","Identifier":"{StartDate}","Value":"10\/21\/2012"}]},{"Content":"<product><data price = \"250\" discountAmount=\"{DiscountAmount}\" startDate=\"{StartDate}\" ><\/data><\/product>","Description":null,"Identifier":"2","Name":"Dollar off Promo","Tokens":[{"DataType":"integer","Identifier":"{DiscountAmount}","Value":"5"},{"DataType":"date","Identifier":"{StartDate}","Value":"10\/21\/2012"}]}]
  • 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-05-31T11:38:54+00:00Added an answer on May 31, 2026 at 11:38 am

    observableArrays do not automatically make all of the properites of the items that they hold observable. An observableArray will only notify subscribers when you manipulate the array itself (push, pop, slice, etc.) or replace the array entirely.

    So, in your case, you would need to map data.Tokens to AttributeToken instances in a similar manner to how you are mapping the overall data or look at using something like the mapping plugin.

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

Sidebar

Related Questions

Thanks to those who answered my last couple questions, I got the following code
Following up from my last question @ stackoverflow.com/questions/7049245/ I got a couple of answers
I've got a winform app in visual studio 2010. My app does the following
I've got the following code inside a <script> tag on a webpage with nothing
I've posted the same question here and I've also got couple of good answers
Howdy, I've got another question regarding phone 7... I want to generate a couple
I got asked this question on a interview for Google a couple of weeks
A couple of questions regarding the following code: @implementation NSArray (Find) - (NSArray *)findAllWhereKeyPath:(NSString
I've got a couple questions if someone could shed some light. I've written a
Lets say i got couple Objects named as txt1 and another object as lbl1.

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.