rejetto forum

Author Topic: The Throwback (retro) template. With large folder and mobile support.  (Read 59968 times)

Offline dj

  • Tireless poster
  • ****
  • Posts: 230
  • 👣 🐾
    • View Profile
    • PWAs
Re: Need help with file delete feature
« on: July 09, 2018, 06:27:37 PM »
Code: [Select]
{.if|{.get|can delete.}|<span onclick='del("%item-url%")'>x</span>.}
and add script
Code: [Select]
function del(it) {
if(!confirm("Delete "+it+"?")) return 0;
var xhr = new XMLHttpRequest();"POST", "%folder%")
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
xhr.onload = function() {document.write(xhr.responseText);}

tested with chrome,FF,Edge

Update: more elegant

Code: [Select]
{.if|{.get|can delete.}|<span class='del' data-it='%item-url%'>x</span>.}
and add script at the end
Code: [Select]
document.querySelectorAll('.del').forEach(function(userItem) {

or use a single event handler

Update2: if {.get|can delete.} slowes down, you can try

Code: [Select]
<span class='del' data-it='%item-url%'>x</span>
and add to function del
Code: [Select]
if (!'{.get|can delete.}') return 0
« Last Edit: July 10, 2018, 04:08:47 PM by dj »

Follow members gave a thank to your post:

Thank-o-Matic 3.0 By Adk Team