Skip to content

Instantly share code, notes, and snippets.

@tarto-dev
Created December 10, 2014 09:56
Show Gist options
  • Select an option

  • Save tarto-dev/f2b10758e979910ab6de to your computer and use it in GitHub Desktop.

Select an option

Save tarto-dev/f2b10758e979910ab6de to your computer and use it in GitHub Desktop.
(function ($) {
Drupal.behaviors.autoUpload = {
attach: function(context, settings) {
$('.form-item input.form-submit[value=Upload]', context).hide();
$('.form-item input.form-file', context).change(function() {
$parent = $(this).closest('.form-item');
//setTimeout to allow for validation
//would prefer an event, but there isn't one
setTimeout(function() {
if(!$('.error', $parent).length) {
$('input.form-submit[value=Upload]', $parent).mousedown();
}
}, 100);
});
}
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment