Last active
May 17, 2016 19:25
-
-
Save lgcantarelli/4c79056c122bf02033c739b416883610 to your computer and use it in GitHub Desktop.
natural language script with erb
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
<h2 class="small">Filtrar por monitoramentos de </h2> | |
<div class="nl-field"> | |
<a class="toggle-options">Todas as Culturas</a> | |
<% cultures_options = Culture.get_options_for_filter %> | |
<ul class="options-list" style="display: none"> | |
<% cultures_options.each do |culture_name, culture_id| %> | |
<li class="culture" value="<%= culture_id %>"> <%= culture_name %> </li> | |
<% end %> | |
</ul> | |
<%= select_tag "filters[culture_id]", options_for_select(cultures_options, (params[:filters][:culture_id] if params[:filters])), style: "display: none" %> | |
</div> | |
<script> | |
$(".toggle-options").click(function() { | |
$(this).siblings("ul.options-list").toggle(); | |
}) | |
$("ul.options-list li").click(function() { | |
var selectSelector = "#filters_" + $(this).attr("class") + "_id"; | |
$(selectSelector).val($(this).val()); | |
$(this).parent().siblings("a.toggle-options").text($(this).text()); | |
$(this).parent().fadeOut(); | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment