Re: [web2py] Re: Component within component

47 views
Skip to first unread message

Richard Vézina

unread,
Apr 26, 2016, 9:30:21 AM4/26/16
to web2py-users
Component inside component can work theoritically but you will have to craft your own ajax... the web2py LOAD() ou web2py_component() not going to work...

Richard

On Mon, Apr 25, 2016 at 6:41 PM, <webm...@trytha.com> wrote:
Note:  This may also have something to do with fancybox, which is what I use for the modal.


On Monday, April 25, 2016 at 3:35:09 PM UTC-7, webm...@trytha.com wrote:
I have the following general setup:

Main Page - basically just a container that holds the...

...Infinite Pagination Pictures Component - loads 10 pictures and my comment() component (one for each picture), which when clicked, opens the...

...Picture Modal - a component that loads in a modal on top of the other component to display the picture you clicked on.


I use LOAD() for all of these.  Here's my problem:  If I try to load my comment() component in the modal as well, all the comment() components in the Infinite Pagination Pictures Component reload as well.  I have separate namespaces based on whether comment() is in a modal or not, but this seems linked to my need to put "{{include 'web2py_ajax.html'}}" in the view of any component that has components within it.  

Is it just not supported to have a sub-component load a component that is also present in the parent-component?  I actually created an infinite loop doing something similar not long ago.

As a workaround, I've been loading the component with JS calling AJAX, which works fine:

//- Load the comments component.
span(id="load-comments"
data-url="{{=URL('social', 'comments', 'comments.load', vars=dict(pic_id=pic_id, comment_open='True'))}}"
data-target="pics-comment-container")
//- AJAX container to load comments.
div(id="pics-comment-container")
//- AJAX call to load comments in the appropriate container.
script.
$(document).ready(function (e) {
elem = $('#load-comments'); // elem = $(e.target)
url = elem.attr("data-url");
target = elem.attr("data-target");
web2py_ajax_page("GET", url, "", target);
return false; // e.preventDefault()
});


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony

unread,
Apr 26, 2016, 11:04:48 AM4/26/16
to web2py-users
On Tuesday, April 26, 2016 at 9:30:21 AM UTC-4, Richard wrote:
Component inside component can work theoritically but you will have to craft your own ajax... the web2py LOAD() ou web2py_component() not going to work...

You can nest components using LOAD or $.web2py.component() -- no need to craft your own Ajax.

Anthony

Richard Vézina

unread,
Apr 26, 2016, 1:11:52 PM4/26/16
to web2py-users
Think I try that in the pass and it wasn't working... Let me find the thread in question see if it was the case...

--

Richard Vézina

unread,
Apr 26, 2016, 1:14:38 PM4/26/16
to web2py-users
https://groups.google.com/d/msg/web2py/I6xhaSaQCdE/sjSeYBHjMcUJ

Massimo's suggest also to use RactiveJS...

Richard

Anthony

unread,
Apr 26, 2016, 2:44:38 PM4/26/16
to web2py-users
On Tuesday, April 26, 2016 at 1:11:52 PM UTC-4, Richard wrote:
Think I try that in the pass and it wasn't working... Let me find the thread in question see if it was the case...

Works for me, at least in the simple case. Perhaps you were doing something more complex.

Anthony

Richard Vézina

unread,
Apr 27, 2016, 10:25:07 AM4/27/16
to web2py-users
The web2py autocomplete already involve componization + component in the main controller container... The issue was the autocomplete which hang... So I guess that it should use web2py_component() instead of LOAD() but this involve a lot of rewrite of web2py autocomplete...

I solve it by removing higher level component I had more page reload and more vars to pass throught url but it make things working...

Richard

--
Reply all
Reply to author
Forward
0 new messages