On Nov 28, 2006, at 9:57 AM, iain duncan wrote:

>
> I'm curious what others think is the TurbogearsBOB practice here ;)
>
> When using widgets that get pulled into templates, how do you organize
> the id and class tree and where do you put these?
>
> Do you make divs in the page template and then call the widget? Or do
> you put the id tags that will get used for dom swapping in the  
> widget? I
> seem to be suffering from too many layers of pointless divs right now
> and am trying to clean house a bit.
>
> Is this the Crustimony Proceedcake?
>
> ( in template )
> <div id="block_cart">${cart_widget()}</div>
>
> ( in js )
> - download new rendered widget via ajaxy goodness
> - swapDOM or replace innerHTML of $("block_cart")
>
> I notice the above means I have a bit of divitis going on, but maybe
> that is neither here nor there. Would be interested in hearing  
> thoughts
> on what people have found best for organizing this kind of stuff.
> Working my way through the new book, I feel pretty swamped with  
> choices
> of how to layout. Which is cool, but notes from the field would be  
> good.
> =)

Depends exactly what you're trying to accomplish. For the case you're  
describing (ajaxly swaping a widget) what I usually do is what you're  
doing: placing the widget in a container and then calling a  
controller method that returns a rendered widget to swap the contents  
of the container with innerHTML.

However, if I just need the DOM id of the widget to initialize some  
JS structure (like TinyMCE or SelectShuttle) does, I usually use the  
"field_id" template variable to refer to it (instead of refering to  
the container and looking for it's first child). However, as I've  
mentioned many times already, one "limitation" (at least for my  
liking) of widgets is that you can only access this variable inside  
update_params or inside the template, which makes hard (IMO) to pass  
this info around to "connect" different widgets.

Alberto

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to