-->

show images in checkbox collection

2019-07-26 22:15发布

问题:

I use best_in_place (it's not important for my question).

I want to show images instead of the checkbox.

my images are found in: public/images.

so I tried:

<%= best_in_place task, :done,:classes => 'highlight_on_success', type: :checkbox, collection: [image_tag("/images/checkbox_yes.gif"), image_tag("/images/checkbox_no.png")] %>

unfortunately, the default image of the checkbox (should be the first image) is shown as -, and when I press it, I saw the second image.

I tried to check if there is a problem with my first image, so I changed my code into:

<%= best_in_place task, :done,:classes => 'highlight_on_success', type: :checkbox, collection: [image_tag("/images/checkbox_no.png"), image_tag("/images/checkbox_yes.gif")] %>

But the default image (should be the second image) was shown as -, and when I pressed it, I saw the first image.

please help.

回答1:

This issue is addressed in a recent pull request, so update your best_in_place version to get this issue resolved. As can be seen from the test code your syntax should be fine.