Mojolicious::Lite how to refresh table only

83 views
Skip to first unread message

Luc Larochelle

unread,
Mar 21, 2018, 11:43:58 AM3/21/18
to Mojolicious
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 ...

Dan Book

unread,
Mar 21, 2018, 11:59:45 AM3/21/18
to mojol...@googlegroups.com
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

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted
Message has been deleted

sri

unread,
Mar 23, 2018, 6:41:29 PM3/23/18
to Mojolicious
Two messages have been deleted in this thread, and it was not done by one of the moderators. We have no idea what happened.

--
sebastian

Tekki

unread,
Mar 26, 2018, 2:18:31 AM3/26/18
to Mojolicious
@Luc: I see your example in the e-mail from Saturday.
As Dan said, you shouldn't use jQuery, but a framework like vue.js that refreshes the UI automatically when the underlying data changes. Then don't send HTML code as response to the search query, but JSON data and let the JS framework care about the "ugly details" (Dan) like iterating through the table rows.

Tekki

unread,
Mar 26, 2018, 11:38:42 AM3/26/18
to Mojolicious
Here you see an example: https://gist.github.com/Tekki/2785aadba9cf9e7f2c01e279f750fd41

Am Montag, 26. März 2018 08:18:31 UTC+2 schrieb Tekki:
As Dan said, you shouldn't use jQuery, but a framework like vue.js ...

Myf White

unread,
Mar 26, 2018, 5:30:33 PM3/26/18
to mojolicious
Alternatively to vue.js is mithril.js. It can be a bit easier to get started with than vue.js, but doesn't have vue's full feature set. But for something like this it works a treat.

Kind Regards,
Myf White

Phone: 0413 757 052
Email:
myfw...@gmail.com

--

Luc Larochelle

unread,
Apr 15, 2018, 12:57:03 AM4/15/18
to Mojolicious
Hi everyone, thanks for taking the time to respond. I'm off for 5 weeks, but I'll look into this and reply to this thread later in May.

Thanks for the suggestions / explanations.

Best,
Luc

Reply all
Reply to author
Forward
0 new messages