javascript - KnockoutJs 1.3 beta. _destroy:false has same result on ui as _destroy:true -
using asp.net mvc, passing viewmodel down , getting knockout map viewmodel , bind this.
this working fine me, trying track deletions.
i thought able adding _destroy property setting false.
i hoped ui ignore until destroy set true.
but not seem case , mere presence of property causing treated destroyed.
is bug or handling wrong?
many thanks, kohan
var model = [{"id":1,"name":"bikes","parent":null,"_destroy":false}, {"id":2,"name":"components","parent":null,"_destroy":false}, {"id":3,"name":"clothing","parent":null,"_destroy":false}, {"id":4,"name":"accessories","parent":null,"_destroy":false}, {"id":5,"name":"mountain bikes","parent":1,"_destroy":false}, {"id":6,"name":"road bikes","parent":1,"_destroy":false}, {"id":7,"name":"touring bikes","parent":1,"_destroy":false}, {"id":8,"name":"handlebars","parent":2,"_destroy":false}] ;
none of above elements show. "_destroy": null has same effect.
working example of problem...
http://jsfiddle.net/jy53e/6/
update: seems issue mapping extension.
what happening sending _destroy
through mapping plugin , coming out observable. knockout not expect observable (a function), when check if (_destroy)
result true, because _destroy
function , not unwrapped see value.
you can like: http://jsfiddle.net/rniemeyer/jy53e/7/ prevent _destroy
getting made observable.
so, use mapping options:
var mappingoptions = { create: function(options) { return ko.mapping.fromjs(options.data, { copy: ["_destroy"] }); } };
Comments
Post a Comment