Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confirm on file delete? #814

Closed
rizqyhi opened this issue Jan 16, 2015 · 9 comments
Closed

Confirm on file delete? #814

rizqyhi opened this issue Jan 16, 2015 · 9 comments

Comments

@rizqyhi
Copy link

rizqyhi commented Jan 16, 2015

Hi, is there any method to show a confirm dialog when deleting the file?
I've tried using removedfile event, but the file has been removed when the confirm modal is showed. Maybe listen to button when clicked will work? Any suggestion?

Thank you for a great plugin. :)

@rizqyhi
Copy link
Author

rizqyhi commented Jan 28, 2015

no prob, I've solved this one. Thanks. :)

@rizqyhi rizqyhi closed this as completed Jan 28, 2015
@davidcelis
Copy link

@rizqyhi How’d you solve this one?

@rizqyhi
Copy link
Author

rizqyhi commented Feb 19, 2015

@davidcelis rather than using default addRemoveLinks option, I manually created the remove button as the wiki said. Inside the click event, I used confirm() function to call my ajax delete.

Just that. :)

@jeremyraybrown
Copy link

The following link has a solution:

78ab99a

@iswiboni
Copy link

on the removeFileEvent = function(e) {

        if (_this.options.dictRemoveFileConfirmation) {

          return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() {
            return _this.removeFile(file);
          });
        } else {

          return _this.removeFile(file);
        }

replace with:

        if (_this.options.dictRemoveFile) {

          return Dropzone.confirm(_this.options.dictRemoveFile+" this file?", function() {
            return _this.removeFile(file);
          });
        } 

@Kaylinka
Copy link

Or you could simply set dictRemoveFileConfirmation :)

@mandeepsapkota
Copy link

Upon cancelling the confirmation box, the thumbnail is removed too!
Is there any way not to remove the thumbnail when user cancels the removal?

@hackhowtofaq
Copy link

@mandeepsapkota

Set

...
dictRemoveFileConfirmation:  "Are you sure?"
...

@jomtoledo
Copy link

If you override removedFile function, you can add customised script to confirm deletion as the file preview won't be automatically removed.

For example:

new Dropzone("#form_sr_safetyitem_details #form_sr_safetyitem_details_dropzone", {
        autoDiscover: false,
        uploadMultiple: true,
        parallelUploads: 1,
        maxFiles: 10,
        addRemoveLinks: true,
        removedfile: function (file) {

               //This is where you can add custom script to confirm deletion; You could use Sweetalert 2 or whatever you prefer than the ugly JS ugly alert box

               //This will manually removed the file
               file.previewElement.remove();
        }
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants