customize file_field button ruby on rails -
i'm trying rid of ugly button rails has default file upload. want add glyphicon
<%= f.file_field :image_url, class:"glyphicon glyphicon-camera" %>
this didn't work , have tried other things in different post saw on page, don't attach file.
as suggested here bootstrap filestyle, can use bootstrap's filestyle style file upload buttons.
step-1: add layout application.html.erb
i have added bootstrap filestyle library cdn. should make sure have both jquery , boostrap loaded.
<script type="text/javascript" src="https://cdn.jsdelivr.net/bootstrap.filestyle/1.1.0/js/bootstrap-filestyle.min.js"> </script>
step-2: add corresponding js
file:
$(":file").filestyle({input: false});
step-3: image_url
file field follows:
<%= f.file_field :image_url,class: "filestyle", "data-input" => false %>
Comments
Post a Comment