Semantic UI File Upload Button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.field | |
.ui.button.fake-file-field | |
%i.upload.icon | |
%span.button-text Choose file | |
.hidden-file-field | |
= f.file_field :file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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