Add swipable delete to all doodads on index
This commit is contained in:
parent
00fe1f1e5a
commit
8d59463f43
@ -15,6 +15,30 @@
|
||||
%p= link_to '+ New Doodad', new_doodad_path
|
||||
= render @doodads
|
||||
|
||||
:javascript
|
||||
function destroyDoodad(doodad_id) {
|
||||
return fetch("/doodads/" + doodad_id, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json"
|
||||
}
|
||||
})
|
||||
.then(response => response)
|
||||
};
|
||||
// var s2 = Swiped.init({ query: '.bar li', list: true, left: 200, right: 200 });
|
||||
var index_doodad_swiped = Swiped.init({ query: '#doodads .doodad',
|
||||
list: true,
|
||||
left: 200,
|
||||
right: 200,
|
||||
onOpen: function() {
|
||||
var doodad_id = this.elem.className.split("-")[1];
|
||||
destroyDoodad(doodad_id)
|
||||
.then(results => console.log(results));
|
||||
this.destroy(true)
|
||||
}
|
||||
});
|
||||
|
||||
-# #canisters
|
||||
= render @canisters
|
||||
- if current_user.signed_in?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user