Reputation: 658
I have a select box to show list shipments details. when user mouse over through each option, I need to show a preview of each option with more details. have any solution for this problem with rails tags
<%= select_tag 'cashed_shipment', options_from_collection_for_select(@cached_shipments,:id,:cached_shipment_detail,prompt: true) %>
And in model, i wrote a method return the markup for each option
def cached_shipment_detail
"<div class= 'dropdown-option'>
<div class ='dropdown-header'> #{vessel_name} | #{voyage_number} | #{loading_date}</div>
<div class = 'dropdown-preview'> more detail preview here </div>
</div>
end
but the above script print as text not as markup, How I can solve this.
Upvotes: 0
Views: 139
Reputation: 7777
Try to the following
def cached_shipment_detail
html = <<-HTML
<div class = "dropdown-option">
<div class = "dropdown-header"> #{vessel_name} | #{voyage_number} | #{loading_date}</div>
<div class = "dropdown-preview"> more detail preview here </div>
</div>
HTML
html.html_safe
end
Hope to help
Upvotes: 0
Reputation: 2624
Use :html_safe
!
def cached_shipment_detail
"<div class= 'dropdown-option'>
<div class ='dropdown-header'> #{vessel_name} | #{voyage_number} | #{loading_date}</div>
<div class = 'dropdown-preview'> more detail preview here </div>
</div>".html_safe
end
Upvotes: 0