Note that there are some explanatory texts on larger screens.

plurals
  1. POdata-bind for Button click function gives error with knockout
    primarykey
    data
    text
    <p>I get error of "Unable to parse Binding, ReferenceError: 'calculateTotalPrice' is undefined; Bindings value: click: calculateTotalPrice</p> <p>below is my simple code snippet</p> <pre><code>&lt;div style="background-color:black; color:white; overflow:scroll; height:350px;width:300px" id="pricesku"&gt; &lt;span id="total" data-bind="text: totalCost"&gt;&lt;/span&gt; &lt;ul data-bind="foreach: price_quantity" style="list-style-type:none;"&gt; &lt;li&gt; &lt;button data-bind="click: calculateTotalPrice(price)"&gt;CLICK THIS TO UPDATE TOTAL&lt;/button&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>But when I do, click and provide function name, get an error above.</p> <p>This is my View Modal</p> <p>function ViewPriceObjectOnWeb(d) {</p> <pre><code>this.price_quantity = ko.observableArray(d); this.totalCost = ko.observable(100); this.calculateTotalPrice = function (p) { var tp = this.totalCost() + p; //$('#total').text(tp); } </code></pre> <p>}</p> <p>and on document ready i make AJAX Call that brings Data from server (this works fine) as below</p> <pre><code>$(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); } }); }); </code></pre> <p>Can anyone help me what I am doing wrong here(i bet i am)? Thx in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload