Rh Jov
Rh Jov

Reputation: 115

Titanium delete TableViewRow, model-view binding should automatically reflect tableview

This is how I delete a tableviewrow on a longclick event of a tableview (android) $.tableview.deleteRow(e.index); , but this just removes the row. How do I also remove the data on my tableviewrow which will in turn remove it from collection via model id, and model-view binding should automatically reflect this in tableview.Any Ideas?Thank You.

Upvotes: 1

Views: 1160

Answers (1)

Aaron Saunders
Aaron Saunders

Reputation: 33345

you need to delete the model object from the collection which will then trigger the appropriate events to update the table.

So in your longpress event

$.tableview.deleteRow(e.index);
collection.models[e.index].destroy() // should delete model, use index to get model
                                     // from the collection

collection.fetch();                  // should force table to update

Upvotes: 2

Related Questions