Thanks, that was a worthy hint.
I have defined filter-menu to handle a hash/enum - at least it works
for me.
Maybe somebody can add a good patch to the original tag, in order to
handle different kinds of options...
<def tag="filter-menu" attrs="param-name, options, no-filter, id">
<% no_filter ||= "All" %>
<form action="&request.request_uri" method="get" class="filter-menu"
merge-attrs="id">
<div>
<% selected = options.detect { |o|
if o.is_a? Array
o[1].to_s==params[param_name.gsub('-', '_')]
else
o.to_s==params[param_name.gsub('-', '_')]
end
} %>
<select-menu name="¶m_name" options="&options"
selected="&selected"
first-option="&no_filter" merge-params/>
</div>
</form>
</def>
In order to make use of the definition in application.dryml I also had
to include this line in the top:
<include src="rapid" plugin="hobo"/>
Best regards,
Sebastian
On 23 Jun., 02:15, kevinpfromnm <[email protected]> wrote:
> <def attrs='param-name, options, no-filter, id' tag='filter-menu'>
> <% no_filter ||= "All" %>
> <form class='filter-menu' action='&request.request_uri' method='get'
> merge-attrs='id'>
> <div>
> <% selected = options.detect {|o|
> o.to_s==params[param_name.gsub('-', '_')] } %>
> <select-menu name='¶m_name' options='&options'
> selected='&selected' merge-params first-option='&no_filter'/>
> </div>
> </form>
> </def>
>
> That's the source of filter menu. quick fix is to copy it and write
> your own tag for it but replace the <% selected = ... %> line to work
> for your input.
>
> On Jun 22, 5:44 pm, Togg <[email protected]> wrote:
>
> > I already saw that there were problems reported with filter-menu in
> > the past, but I couldn't find a fix for my problem (lighthouse #314,
> > #369, #725).
> > When I use a hash to fill the filter-menu, the filtering itself works,
> > but the determination of the selected item does not. Using an array
> > works, but then I cant use different values and names.
>
> > in the dryml:
> > <filter-menu param-name="show" options="&@myvar"/>
>
> > In the controller:
> > Array:
> > @myvar = ["1 Minute", "5 Minutes"]
>
> > Hash:
> > @myvar = {"1 Minute" => 60, "5 Minutes" => 300}
>
> > The problem seems to be the code in rapid_plus.dryml, line 166:
> > <% selected = options.detect {|o|
> > o.to_s==params[param_name.gsub('-', '_')] } %>
>
> > For the hash it concatenates the option -- o.to_s would be "5
> > Minutes300" for example.
>
> > Any idea for a bugfix?
>
> > Thanks,
> > Sebastian
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.