Thursday 15 May 2014

How to display details in edit popup window with knockout.js -


I have a button on the customer list form. When I click on the Edit Special Row button I want to show details in the edit window.

How to pass the customer ID for the popup window?

  & lt; Button data-bind = "click: $ root.edit" & gt; Edit & lt; / Button & gt; I'm not sure about "Show details in the edit window" bit -  

observation arrays and toggle its visibility on the click. Some types of "chosen customers" also seem like a good idea.

To pass the customer ID around, I showed how to do it.

HTML:

  & lt; H3 & gt; Click on a line to get the customer's ID: & lt; / H3 & gt; & Lt; Div data-bind = "foreach: customer" & gt; & Lt; Div data-bind = "click: $ root.selectCustomer" class = "person" & gt; & Lt; Div & gt; Customer's Name: & lt; Span data-bind = "text: name" & gt; & Lt; / Span & gt; & Lt; / Div & gt; & Lt; Div & gt; Customer Age: & lt; Span data-bind = "text: age" & gt; & Lt; / Span & gt; & Lt; / Div & gt; & Lt; Div & gt; Customer ID: & lt; Span data-bind = "text: id" & gt; & Lt; / Span & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

JS:

  var vm = function () {this.customers = ko.observableArray ([{Name: Jim ID: "2"}, {name: "jill", age: "30", id: "3", "40", id: "1"}, {name: "jack", age: "20", id: "3 "}]); This.selectCustomer = function (customer) {warning (customer.id);};}; Ko.applyBindings (new VM);  

In this code, the entire customer The object has been passed to choose the customer (), and the properties of all the clients can be modified.


No comments:

Post a Comment