Hi Dan, thank you very much for taking the time to help me on this. Here's my related jquery function. This is not enough to achieve what I'm trying to do ?
$("#searchForm").on('submit', function (e) { e.preventDefault(); var text = $("#searchBox").val(); $.get('/mysearch/' + text, function () { window.location.reload(); }); }); Here's the route, where " search" is actually a template containing only the table itself (see below) as part of the layout. What am I doing wrong ? :/ get '/mysearch/:expr' => sub { my $c = shift; my $hosts; my @list = grep { $_->{'hostname'} =~ /$c->param('expr')/ } @{$c->devices}; $c->redirect_to('/') unless (@list); foreach (@list) { $hosts->{$_->{hostname}} = $_; } $c->stash->{hosts} = $hosts; return $c->render('search'); }; @@search.html.ep % layout 'mylayout'; <table class="table"> <thead> <tr> <th>Hostname</th> <th>IP</th> <th>Groupe</th> <th>Auth</th> <th>Protocol</th> </tr> </thead> <tbody> % my $nodes = stash 'hosts'; % foreach my $host ( sort keys %$nodes ) { % my $class = "hoverDiv"; % $class = "bg-danger" if ($nodes->{$host}->{incomplete}); <tr class=<%=$class%>><td><a href="#" data-target-id=<%= $nodes->{$host}->{hostname} %> data-toggle="modal" data-target="#EditModal" class="ls-modal"><%= $nodes->{$host}->{hostname} %></a></td><td><%= $nodes->{$host}->{ip}%></td><td><%= $nodes->{$host}->{groupe}%></td><td><%= $nodes->{$host}->{auth}%></td><td><%= $nodes->{$host}->{protocol}%></td></tr> % } </tbody> </table> Best regards, Luc On Wednesday, 21 March 2018 11:59:45 UTC-4, Dan Book wrote: > > Refreshing the page and refreshing the table are two different things. The > latter you would need to do in javascript, ideally with a framework like > vue or react that can handle the ugly details. If you refresh the page, you > only need to have the route provide the subset of the data instead of the > full set when it receives the search term. > > -Dan > > On Wed, Mar 21, 2018 at 11:43 AM, Luc Larochelle <llaro...@gmail.com > <javascript:>> wrote: > >> Hi everyone, >> >> I built a single page application to display content in a table with >> Mojolicious Lite. This works fine, the first time the data is rendered. >> >> I pass the values through the stash and in my template, I use a for loop >> to go through the structure and display in the web page. >> >> The problem is selecting a subset of the data (a search box for example). >> I don't understand how to pass the values to the stash and refresh the page. >> >> The stash changes with the desired data after a call to a get sub (for >> example get '/search/:expr' ) but it will never render. As if it gets >> rendered twice, since the final result is the whole table being displayed. >> >> What would be the best way to achieve this ? >> >> Please help ... >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Mojolicious" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to mojolicious...@googlegroups.com <javascript:>. >> To post to this group, send email to mojol...@googlegroups.com >> <javascript:>. >> Visit this group at https://groups.google.com/group/mojolicious. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com. To post to this group, send email to mojolicious@googlegroups.com. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.