data binding - Knockout Cart Editor Example questions : extending cascading drop-downs with nested arrays and functions -
here's my fiddle attempt combining code on knockout cascading cart editor live example on knockoutjs.com site, , rp niemeyer's example of data binding nested arrays try , achieve cascading cart extended product options in functional format given niemeyer.
- why doesn't quantity field update subtotal?
- why doesn't 'remove' work?
- why formatcurrency(price) produce 'unable parse bindings' error?
- why happen changing product field doesn't update price if 'add product' button pressed change appear in next line?
- in niemeyer's example 'add-product' , methods inside scope of functions rather cartline, copied 'subtotal' method - better place handle these operations?
thanks work of s.sanderson, r.p.niemeyer, j.papa incredible effort in community promote knockout. it's awesome!
alright, fiddle bit more complicated needs be, have tried leave structure alone in case planning expand. have few questions though, i'll @ end. first, questions:
you had several quantity , subtotal properties, 1 on each object (line, category, , product). layering had confused them (and me, honestly). removed quantity , subtotal properties on models, didn't make sense anyway, left them in data. should sort out want like.
your layering wrong, removeline looking function on cartline, , sending product, had function on viewmodel , needed cartline. moving remove line outermost context fixed this.
i didn't error.
your price not getting update properly. context-layering issue.
i think linked wrong fiddle niemeyer, 1 linked has no product in it.
here working fiddle code. it's still bit messy because, again, tried not mess more needed to. should consider restructuring data and/or viewmodels though, doesn't need complex. removed of layering though, since didn't match viewmodel.
also, category.subscribe method inside computed observable subtotal. moved outside, onto model.
note: using knockout2.0 in fiddle. please consider updating. knockout1.3beta not implement control flow in same way, , causing seperate error didn't talk about.
so, questions:
- why there quantity on both product , options in data , object defintions?
- why there subtotal on each of product, category , cartline?
- why there grandtotal on menu , viewmodel? 3a. why there grandtotal on menu @ all? makes no sense.
Comments
Post a Comment