Skip to content

Instantly share code, notes, and snippets.

@yu-smc
Created June 30, 2018 07:02
Show Gist options
  • Save yu-smc/a015655df6cd9d9c429bb3350cd451e3 to your computer and use it in GitHub Desktop.
Save yu-smc/a015655df6cd9d9c429bb3350cd451e3 to your computer and use it in GitHub Desktop.
hoge
$(document).on('turbolinks:load', function() {
$(function (){
$('#prototype_captured_images_attributes_0_content').on('change',function previewFile(e) {
var preview = $("#selected_image")
var file = e.target.files[0];
var reader = new FileReader();
reader.onloadend = function () {
preview.src = reader.result;
$("#selected_image").attr("src", preview.src);
}
if (file) {
reader.readAsDataURL(file);
} else {
preview.src = "";
}
});
});
$(function(){
$('.cover-image-upload').on('mouseenter', function(){
$(this).css("background-color","rgba(255, 175, 45, 0.4)")
})
$('.cover-image-upload').on('mouseleave', function(){
$(this).css("background-color","#ffffff")
})
});
$(function(){
$('#prototype_captured_images_attributes_0_content').on('change', function(){
$('#show_selected_image').remove();
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment