Skip to content

Instantly share code, notes, and snippets.

@stecb
Created October 26, 2012 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stecb/3958943 to your computer and use it in GitHub Desktop.
Save stecb/3958943 to your computer and use it in GitHub Desktop.
drop from url (for carrierwave)
- content_for :javascript_page do
:javascript
$(document).bind('drop', function(e) {
var url
, target = $(e.target)
, remote_avatar = $('#user_remote_avatar_url')
;
if (target.hasClass('dropzone')) {
url = $(e.originalEvent.dataTransfer.getData('text/html')).filter('img').attr('src');
if (target.hasClass('attachments-drop"')) {
return;
} else {
var form = remote_avatar.val(url).parents('form');
form.submit();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment