Skip to content

Instantly share code, notes, and snippets.

@nickclyde
Created March 8, 2017 20:31
Show Gist options
  • Save nickclyde/d79b4ff032af7070ea0d6f5e9d609030 to your computer and use it in GitHub Desktop.
Save nickclyde/d79b4ff032af7070ea0d6f5e9d609030 to your computer and use it in GitHub Desktop.
Semantic UI File Upload Button
.field
.ui.button.fake-file-field
%i.upload.icon
%span.button-text Choose file
.hidden-file-field
= f.file_field :file
// Turn file input into a button
$('.hidden-file-field').hide();
$('.fake-file-field').click(function(e) {
$("input[type='file']").click();
});
$('.hidden-file-field').change(function() {
$('.button-text').text(
$('input[type=file]').val().split('\\').pop()
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment