Note that there are some explanatory texts on larger screens.

plurals
  1. POknockout parent and root binding
    text
    copied!<p>i have a problem with parent and root binding. </p> <pre><code>function SignCell() { var self = this; self.MathSign = ko.observable("+"); self.AdditionCell = ko.observable(""); } function Expression(cell) { var self = this; self.BaseCell = ko.observable(cell); self.AddCell = ko.observableArray([]); } function Condition(active, expression1, sign, expression2, errMassage) { var self = this; self.Active = ko.observable(active); self.Expression1 = expression1; self.Sign = ko.observable(sign); self.Expression2 = expression2; self.ErrMassage = ko.observable(errMassage); } var ViewModel = function() { var self = this; self.ConditionArray = ko.observableArray([ new Condition(true,new Expression(""),"=",new Expression(""),"") ]); self.RemoveExpr1 = function () { var i = self.ConditionArray.indexOf(arr); self.ConditionArray()[i].Expression1.AddCell.push(new Expression()); }; }; </code></pre> <p>and html </p> <pre><code>&lt;tbody data-bind="foreach: ConditionArray"&gt; &lt;tr&gt; &lt;td&gt;&lt;input class="input-small" data-bind="value: Expression1.BaseCell"/&gt; &lt;table&gt; &lt;tbody data-bind="foreach: Expression1.AddCell"&gt; &lt;tr&gt; &lt;button data-bind="click: $parent.RemoveExpr1" class="btn btn-danger"&gt; &lt;i class="icon-minus-sign icon-white"&gt;&lt;/i&gt;&lt;/button&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>i can't call function <strong>self.RemoveExpr1</strong> using <strong>click: $parent.RemoveExpr1"</strong> have you any ideas how to solve this problem</p>
 

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