A working example for swipeout-delete on virtual-list
Hi there, thank you for framework7. Is there an existing example to demonstrate swipeout-delete on a virtual-list to successfully update the virtual-list after the delete event?
Currently, I am facing either a single empty row (after delete) or an entire empty virtual-list (when i use .update() or .deleteItem())
Any advice? Appreciate your help in advance! I have also filed the question to stackoverflow
render :
return '<li class="swipeout"> ' +
' <div class="swipeout-content"> ' +
' <a href="#" class="item-content item-link item-notifications"> ' +
'notification content' +
' </a> ' +
' </div> ' +
' <div class="swipeout-actions-right"> ' +
' <a href="#" class="swipeout-delete swipeout-overswipe" onclick="deleteNotification(' +
notification.NotificationID + ');">delete</a> ' +
' </div> ' +
' </li>';
var deleteNotification = function (id) {
for (var i = 0; i < notifications.vl.items; i++) {
var temp = notifications.vl.items[i];
if (temp.NotificationID == id) {
notifications.vl.deleteItem(i);
break;
}
}
}
not the best practice but a work around with for loop when swipe out fire delete
Thanks for the answer @mohshraim
In the end, I use the following solution:
At virtual-list:
onItemBeforeInsert: function(list,item){
if($$(item).hasClass("added") == false){
$$(item).on('swipeout:delete', function (e) {
///update webservice
})
$$(item).addClass("added")
}
}
At javascript
function complete_button(time){
for(var i = 0; i < index_vl.items.length; i++){
if(index_vl.items[i].created_at == time){
index_vl.deleteItem(i)
index_vl.update()
break
}
}
}
At template
<a id="complete_button" onclick="complete_button('{{created_at}}')"
class="demo-actions bg-green swipeout-delete swipeout-overswipe">
<span class="small">Complete</span>
</a>
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.