Question

attempting to call $(this).fineUploader("getButton", id); in the submit event handler and getting undefined as a result.

I assume the buttons are being tracked since access to the button is available within the validate and upload events. However, I really would like to know which button was clicked during the submit event so I can set parameters for the specific file upload. The validate event has no file id present to associate specific parameters

In Response to Comments, additional information:

Fineuploader Version 4.1.1

I have tried the scenario in many configurations and getButton method call never works in the submit handler

myfineuploader.on('submit', function(event, id, name) {
  var button = $(this).fineUploader('getButton', id);
  console.log(button);  // Button always shows undefined here
}

The buttons are defined as spans outside of the template, setup like this in the config:

button: $("#button1"),
extraButtons: [
   {
      element: $("#button2")
   }
]
Was it helpful?

Solution

The button is not associated with the file until after the submit event callback has completed. This was done to ensure that mappings were created only for files that passed all possible validation steps, since it is possible to reject a file in your "submit" handler as well. After some thought, it may be best to create this button to file mapping as soon as we have created an ID for this file internally. I've created an item in our issue tracker to deal with this.

If you move your logic into a "submitted" event handler instead, you should be good to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top