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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:09:07+00:00 2026-06-15T03:09:07+00:00

I get error of Unable to parse Binding, ReferenceError: ‘calculateTotalPrice’ is undefined; Bindings value:

  • 0

I get error of “Unable to parse Binding, ReferenceError: ‘calculateTotalPrice’ is undefined;
Bindings value: click: calculateTotalPrice

below is my simple code snippet

<div style="background-color:black; color:white; overflow:scroll; height:350px;width:300px" id="pricesku">
<span id="total" data-bind="text: totalCost"></span> 
<ul data-bind="foreach: price_quantity" style="list-style-type:none;">
<li>                  
<button data-bind="click: calculateTotalPrice(price)">CLICK THIS TO UPDATE TOTAL</button>                   
</li>             
</ul>
</div>

But when I do, click and provide function name, get an error above.

This is my View Modal

function ViewPriceObjectOnWeb(d) {

this.price_quantity = ko.observableArray(d);
this.totalCost = ko.observable(100);
this.calculateTotalPrice = function (p) {
var tp = this.totalCost() + p;
//$('#total').text(tp);
}

}

and on document ready i make AJAX Call that brings Data from server (this works fine) as below

$(document).ready(function () {   
var sku = "abcd";
$.ajax({
    url: "/api/values?clientSKU=" + sku, //this would give SKU/Price collection as JSON Serialized object from .NET/Server Side
    dataType: "json",
    asyc: false,
    type: "get",
    success: function (msg) {
    var skuandprice = $.parseJSON(msg);          
    ko.applyBindings(new ViewPriceObjectOnWeb(skuandprice), document.getElementById('pricesku'));
    },
    error: function (jqXHR, textStatus, errorThrown) {
    alert(textStatus + '  ' + errorThrown);
    }
    });
});

Can anyone help me what I am doing wrong here(i bet i am)? Thx in advance.

  • 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-15T03:09:08+00:00Added an answer on June 15, 2026 at 3:09 am

    When you are inside a foreach loop, Knockout expects any functions or properties in the data-bind to be defined within the entries of the array, which in this case are the values in price_quantity. To access functions and properties that are defined in the object that holds the array, you use the $parent identifier. So to use calculateTotalPrice inside your loop, you need to do:

    <li>                  
        <button data-bind="click: $parent.calculateTotalPrice">CLICK THIS TO UPDATE TOTAL</button>                   
    </li>
    

    The view model:

    function ViewPriceObjectOnWeb(d) {
        var self = this;
        self.price_quantity = ko.observableArray(d);
        self.totalCost = ko.observable(100);
        self.calculateTotalPrice = function (p) {
            var tp = self.totalCost() + p;
            self.totalCost(tp);
        };
    }
    

    Working example (using hard-coded prices): http://jsfiddle.net/jonhopkins/fn7vc/2/

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

Sidebar

Related Questions

Why do I get the error: Unable to create a constant value of type
I cannot compile python in pydev in eclipse. I get the following error: unable
I get this error message in LogCat: 06-25 15:17:34.495: E/AndroidRuntime(5891): java.lang.RuntimeException: Unable to start
I get a crazy error and I am unable to see why it happens.
When I compile my application , I get following compile error. Unable to find
I am unable to start the Call activity. I get the following error: android.content.ActivityNotFoundException:
I get error: ORA-06575: Package or function GET_CONC_NAMES is in an invalid state When
Why do I get error in this code?Even if i do not link but
Why I get error with this query on my live server but not on
I have this query and I get error Operand should contain 1 column(s), whats

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.