Templates : how to pass data to other context

44 views
Skip to first unread message

Luc Larochelle

unread,
Feb 28, 2018, 4:12:35 PM2/28/18
to Mojolicious
Is there a way, using the templates, to pass data from context to context ?

For instance, if I open a modal for CRUD operation where I want to populate the content of a form for edit purpose, can I pass the whole hashref to fill the form ? How would one do this ?

I've seen how to use javascript to pass some text, which could be re-used to request the same route again and then use the data to populate the form in the modal, but is there a more elegant way to do this with Mojolicious ?


Luc Larochelle

unread,
Mar 1, 2018, 10:38:47 AM3/1/18
to Mojolicious
I thought about this, maybe if I post/get on click and render a modal template this could do the trick ...

I'm not exactly sure how to achieve this, I'll try and see and keep you posted. If anyone has an idea ...

Luc Larochelle

unread,
Mar 1, 2018, 4:58:08 PM3/1/18
to Mojolicious
Still working on this, I can get on a route/:id but the object returned in the stash is undef. The modal is part of the same template as the list, though. 

Luc Larochelle

unread,
Mar 3, 2018, 10:30:16 AM3/3/18
to Mojolicious
Finally I found out an approach to this problem. Using the jquery api included with bootstrap it gets easy to pass the minimum params and then use $.get or $.post to work with my routes and render.

Stefan Adams

unread,
Mar 5, 2018, 12:56:52 AM3/5/18
to mojolicious
Take a look at the example blog from Mojo::Pg.  I think how it's built would demonstrate what you are trying to achieve.

On Sat, Mar 3, 2018 at 9:30 AM, Luc Larochelle <llaro...@gmail.com> wrote:
Finally I found out an approach to this problem. Using the jquery api included with bootstrap it gets easy to pass the minimum params and then use $.get or $.post to work with my routes and render.

--
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.

Reply all
Reply to author
Forward
0 new messages