Ommadawn
Ommadawn

Reputation: 2730

Bootstrap input file event removing data

I'm using Bootstrap FileInput and it is really cool :)

I've got a problem with some events. I want to know how could I detect when I press on "Remove" button after submitting a file. Here is a pic of what I mean:

remove button

I've used "fileremoved", "filedeleted", "filepredelete", "filebeforedelete",... events (anything about "remove" or "detele"), but they don't work.

What's the event I'm looking for? Am I missing anything?

Thank you!


EDIT:

Here is my little JS code for the events:

$('#file_upload').on('filebatchuploadcomplete', function() {
    console.log("I have pressed the upload button"); // --- Ok, it works!! :)
    // More stuff here...
});

$('#file_upload').on('fileremoved', function() {
    console.log("I have pressed the remove button"); // --- Never shown!! :(
    // More stuff here...
});

Upvotes: 2

Views: 3661

Answers (1)

NDTChan
NDTChan

Reputation: 76

In Bootstrap FileInput newest version, the remove event is fileclear or filecleard (https://plugins.krajee.com/file-input/plugin-events#fileclear).

  • fileclear: This event is triggered when the file input remove button or preview window close icon is pressed for clearing the file preview
  • filecleard: This event is triggered after the files in the preview are cleared.

Ex: $('#input-id').on('fileclear', function(event) { console.log("fileclear"); });

Upvotes: 3

Related Questions