RM wrote:
> Is there any way to make tg widgets readonly? The effect I'm trying to
> create is a readonly form with an Edit button, that "wakes up" the
> widgets to editable. I've done a similar interface in ASP.NET, but
> can't find the support I would need in tg.

What you probably mean is a widget that renders a form field, that is 
read-only. Please note that widgets are not limited to form fields and 
control elements. You can use widgets for all things that get rendered 
through HTML/CSS/JavaScript, for example, a link list in the sidebar, 
google ads, images and so on...

As to your question, just put a texteara with the "readonly" attribute 
and an id in your widget's template and a button with an id too. To the 
latter you can then attach a JavaScript 'onclick' event function that 
toggles the 'readOnly' attribute of the DOM object corresponding to the 
textarea.

You can attach that function directly in your template via the 'onclick' 
attribute, or, not so obtrusive, in a window 'onload' handler or even 
better with a DOMContentLoad event handler (see 
http://dean.edwards.name/weblog/2006/06/again/ for an explanation of the 
issue).

Then attach the JavaScript to the widget via the 'javascript' attribute 
and TurboGears will automatically include it on the page.

I am too lazy to show you some code right now, but if you need help to 
implement this, give us a shout.

Chris

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