webix.confirm in onBeforeDeleteFile - How can I fired SeverSide function?

In onBeforeDeleteFile I want to ask the user to confirm the deletion. That what I have now.
Now I want counting the files and folders before I confirm the deletion. The user should be inform about that.
How can I fired the serverside function from the onBeforeDeleteFile?

Comments

  • edited June 2018
    {
       on: {
          onBeforeDeleteFile: function(id){
             var that = this;
             webix.ajax(...).then(function() {
                if(condition) {
                   webix.confirm("Please confirm", "confirm-warning", function(result){
                      if(result) that.deleteFile(id);
                   });
                }
             });
             return false;
          }
       }
    }
    
  • My code:

    $$("files").attachEvent("onBeforeDeleteFile",function(id){
    webix.ajax().post(page+"?action=removecount&source="+id, function(text, data, xhr){
    dataJson = data.json();
    countFiles=0;
    countFolders=0;
    isCount=false;
    for(var i = 0; i < dataJson.length; i++) {
    var obj = dataJson[i];
    if(obj.data.hasOwnProperty("files_count") && obj.data.hasOwnProperty("folders_count")) {
    countFiles += obj.data.files_count;
    countFolders += obj.data.folders_count;
    isCount=true;
    } else {
    countFiles += 1;
    }
    };
    if(isCount) {
    strText = "Delete "+countFiles+" File(s) and "+countFolders+" Folder(s)?";
    } else if(dataJson.hasOwnProperty("type")) {
    if(dataJson.type == "removefolder"){
    strText = "Delete Folder(s)?";
    } else {
    strText = "Delete File(s)?";
    }
    } else {
    strText = "Delete File(s)?";
    }
    webix.confirm({
    text: strText,
    type:"confirm-warning",
    callback:function(res){
    if(res){
    $$("files").deleteFile(id);
    }
    webix.callEvent("onClick", []);
    }
    });
    });
    return false;
    });

    This is good for me.

    But on which place I place the progress functions?
    The response time is to long without disable the input.

  • you need to show progress just before ajax operation and hide progress on success or error.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion