Is there no easy way to pop an item from an array?
Take this code for example"
Ok so on click we call the delete in the model
So why doesn't this work? :/ It's just popping off the last item in the array instead of the item I'm giving it.
I've tried doing things like this, but end up at the same result
What am I doing wrong?
Take this code for example"
<div id="kendo-bound-resourcelist" data-bind="visible: isVisible" > <div data-role="grid" data-sortable="true" data-bind="source: items" data-columns='["Title", "PMID", "TypeOfMaterial",""]' data-row-template="row-template"></div> </div> <script id="row-template" type="text/x-kendo-template"> <tr class="k-grid-edit-row"> <td> <span data-bind="text: Title"></span> </td> <td> <span data-bind="text: PMID"></span> </td> <td> <span data-bind="text: TypeOfMaterial[0]"></span> </td> <td> <input type="button" data-bind="click: deleteItem" value="Delete" /> </td> </tr> </script>Ok so on click we call the delete in the model
this._viewModel = kendo.observable({ items: [], isVisible: function () { return this.get("items").length > 0 ? true : false; }, deleteItem: function (resource) { this.get("items").pop(resource); } });So why doesn't this work? :/ It's just popping off the last item in the array instead of the item I'm giving it.
I've tried doing things like this, but end up at the same result
var deletedId = resource.data.Id;var items = this.get("items");for (var i = 0; i < items.length; i++) { if (items[i].Id === deletedId) { this.get("items").pop(items[i]); }}What am I doing wrong?