Created
September 28, 2012 15:26
-
-
Save mrsimo/3800518 to your computer and use it in GitHub Desktop.
Ugly helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def filter_dropdown(select_options, options) | |
current_text = select_options.find { |text, filter| filter == options[:current] }.try(:first) || select_options.first.first | |
image = '<img height="6" width="8" src="/img/v/transparent_r1.gif" class="icn icn-ext-ctr-arrow-down">' | |
link = content_tag :strong do | |
link_to("#{current_text} #{image}".html_safe, "#", :"data-simplelayer" => "##{options[:key]}") | |
end | |
uls = content_tag :ul, :id => options[:key], :class => "dropdown", :style => "display:none" do | |
select_options.map do |text,key| | |
klass = (options[:current] == key ? 'selected' : nil) | |
content_tag :li, link_to(text, params.merge(options[:key] => key), :class => klass) | |
end.join.html_safe | |
end | |
<<-EOS.html_safe | |
#{options[:label]} | |
#{link} | |
#{uls} | |
EOS | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fix: in line 6 it should not be
key
butoptions[:key]