javascript - Updating values from select list with Knockout.js -
i trying modify lists , collections tutorial found on knockout.js website allowing editable price rather fixed value.
right lists , data populate correctly when page loads. however, if select new value list price , id not change row. total surcharge changes, row doesn't. also, if change price manually given row, total surcharge doesn't change.
i tried setting individual values observables such shown below, price , id values still don't update when new list item selected, total surcharge
function rowreservation(initialrow) { var self = this; self.row = ko.observable(initialrow); self.rowid = ko.observable(self.row().rowid); self.price = ko.observable(self.row().price); }
so 2 issues can't seem figure out
when new item selected in list, corresponding price , id not change
if price manually changed, total surcharge doesn't update
edit - number 1 of list has been fixed, , 2 partially has.
if change price in 1 of text boxes either row, total surcharge update if row added or other row's name has been changed. basically, it's not immediate change, it's computed when new value introduced. how can make updates automatically? there way subscribe price textboxes?**
the thing need modify in code part in line 17 of html
<input data-bind="value: price" />
into
<input data-bind="value: $data.row().price"/>
when bind 'price' initially, binding price attribute of rowreservation object. when 'row' value changed, value of 'price' attribute not updated. therefore still shows original price.
i changed binding showing price attribute of 'row'. when 'row' changed selecting different item in combobox, price updated price of newly selected row.
basically have
// rowreservationobject {'row': {'rowname': 'standard', 'rowid': 1, 'price': 19.99 }, // --> i'm binding against 'rowid': 1 'price': 19.99} // -- binding against before
if change variable names bit might become clearer you. hope i'm making sense.
Comments
Post a Comment