Quantcast
Channel: knockoutspa Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 3

Commented Issue: New items which are deleted are still posted to server [846]

$
0
0
If you add an item and then delete it from the view, the item is still posted to the server, without a delete also being sent. In DataSet.SaveAll it walks the NewItems array and does the post via the Create function. Wrapping the call to Create with if(this.NewItems[i].EntityState() != spa.entityStates.removed) fixes the issue, but there may be a better way.
Comments: ** Comment from web user: dacendale **

Thanks for the quick reply. Here's a repo created from stripping down what I'm using:
Using a form something like:
<table>
<tbody data-bind="foreach: {data: Items, afterRender: onAfterRender}">
<tr>
<td><input data-bind="click: $parents[0].DeleteRotation" type="button" value="-"/></td>
<td><input data-bind="text: Entity.Name" /></td>
</tr>
</tbody>
</table>
<input data-bind="click: AddRotation" type="button" value="+"/>
<input data-bind="click: Save" type="button" value="Save"/>

You'll get a table of data you are editing. The AddRotation and DeleteRotation properties map to:

self.addRotation = function () {
self.view.AddItem(new spa.dataEntity({
Name: 'Rotation'
}));
};

self.deleteRotation = function (item) {
self.view.DeleteItem(item);
};

With buffered changes, when you press add to create a template item and then decide you don't want it, so press the delete button beside it, when you press save (which just calls SaveAll, not shown) you can see in fiddler that the template item is posted to the server.
I can email a complete solution if necessary.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images