Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No preview nor file link when creating a new instance, fine with editing the instance, but the preview is not refreshed. #19

Open
oasisweng opened this issue Apr 23, 2016 · 0 comments

Comments

@oasisweng
Copy link

oasisweng commented Apr 23, 2016

Following the tutorial, I added both image_preview and attachment_preview to two separate input fields:

<%= f.input :resume, as: :attachment_preview, 
                       wrapper: :horizontal_file_input %>

<%= f.input :image, as: :image_preview, 
                           input_html: { :preview_version => :thumb },
                           wrapper: :horizontal_file_input
                            %>

in new page for my Staff model.

But, when I add a pdf file to attachment preview field. Nothing happened. When I add an image to image preview field, no preview is shown.

The HTML generated for my image preview input is:

<div class="col-md-6">
<label class="image_preview required col-sm-5 control-label" for="staff_profile_attributes_profile_picture_attributes_image">
<abbr title="required">*</abbr> Profile Picture</label>
<div class="col-sm-7">
<input class="image_preview required" type="file" name="staff[profile_attributes][profile_picture_attributes][image]" id="staff_profile_attributes_profile_picture_attributes_image" data-validate="true">
<p class="help-block">Only accepts JPG, JPEG, PNG, GIF format. Do not exceed 2MB.</p>
</div>
</div>

It does not have preview_version setup either.

Then, in my staffs#edit page, I have the same setup. This time, still no link for attachment preview. But there is a preview for image preview field. However, when I change to a new image, it does not refresh the preview.

I did not do any additional setup. I tried:


SimpleForm::FormBuilder.map_type :image_preview, to: SimpleForm::Inputs::ImagePreviewInput
SimpleForm::FormBuilder.map_type :attachment_preview, to: SimpleForm::Inputs::AttachmentPreviewInput

and it doesn't work. I don't think it is related to this issue.

Am I missing some front end setups such as putting some JS file in application.js?

Please help! Thank you!

I am using Rails 4.2.6, Ruby 2.2.3, Simple_form 3.2.1, client_side_validations 4.2.3 and bootstrap 3.3.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant