Created
March 22, 2014 23:38
-
-
Save rtablada/9716101 to your computer and use it in GitHub Desktop.
Allow awesome uploaders in Gumby
This file contains hidden or 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
<div class="append field fancy-uploader"> | |
<input type="text" class="input xwide" placeholder="File"> | |
<input type="file" name="picture"> | |
<div class="primary btn medium"> | |
<button>Upload</button> | |
</div> | |
</div> |
This file contains hidden or 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
(function(){ | |
$('.fancy-uploader').on('click', '.btn', function(ev) { | |
ev.preventDefault(); | |
$(this).siblings('input[type=file]').click(); | |
}); | |
$('.fancy-uploader').on('change', 'input[type=file]', function(ev) { | |
file = this.files[0]; | |
$textBox = $(this).siblings('input[type=text]').first(); | |
$textBox.val(file.name); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment