jfeldstein / jQuery.AjaxFileUpload.js

jQuery plugin to magically make file inputs upload via ajax
408 stars 246 forks source link

Specify a different submit_button for each element #17

Closed raphpar closed 8 years ago

raphpar commented 12 years ago

Hello,

In my case I needed to have a specific submit_button for each element.

I changed the code a lillte bit to handle this. This modification will not impact users that use a unique submit_button for all element, or no submit_button (onchange event)

It's your choice to finaly integrate this code update or not

On my side, I think i'm finish with my modification, thanks a lot, your script is very helpfull and easy to use !!

Raphael P.

jfeldstein commented 8 years ago

Not gonna merge this, it's against jQuery patterns.

Rather than:

console.log($('.inputs').length) // '2'
$('.inputs'). ajaxfileupload({
  submitButton: { first: '#first-btn', second: '#second-btn'}
});

Do

console.log($('.first').length) // '1'
$('.first'). ajaxfileupload({
  submitButton: '#first-btn'
});

console.log($('.second').length) // '1'
$('.second'). ajaxfileupload({
  submitButton: '#second-btn'
});

This way "all the settings apply to all selected elements", rather than passing in more options than apply and processing how to apply them internally. Less magic, more straightforward.

Or just fork as needed.