You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Binkley, Peter" <PB...@mail.library.ualberta.ca> on 2007/10/09 19:54:59 UTC

updating css class in ajax form

I've got a form in which a repeater generates cells of a table. Within each cell there is a select element. I want the css class of the <td> element to be set to the value of the select whenever the select changes. I've done this in the template like this:
 
<ft:repeater id="rows">

<table>

<ft:repeater-rows>

<ft:repeater id="columns">

<tr>

<ft:repeater-rows>

<td class="${repeater.getWidget(repeaterLoop.index, 'foo').getValue()}">

<ft:widget id="foo">

<fi:styling submit-on-change="true"/>

</ft:widget>

</td>

</ft:repeater-rows>

</tr>

</ft:repeater>

</ft:repeater-rows>

</table>

</ft:repeater>

 

I had hoped that the submit-on-change styling would force the <td> to re-render with the new style, but it doesn't; the ajax update is empty. Is there a way to force the <td> to re-render?

 

Thanks for any help,

 

Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: updating css class in ajax form

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Binkley, Peter pisze:
> I've got a form in which a repeater generates cells of a table. Within each cell there is a
> select element. I want the css class of the <td> element to be set to the value of the select
> whenever the select changes. I've done this in the template like this:
> 
> <ft:repeater id="rows">
> 
> <table>
> 
> <ft:repeater-rows>
> 
> <ft:repeater id="columns">
> 
> <tr>
> 
> <ft:repeater-rows>
> 
> <td class="${repeater.getWidget(repeaterLoop.index, 'foo').getValue()}">
> 
> <ft:widget id="foo">
> 
> <fi:styling submit-on-change="true"/>
> 
> </ft:widget>
> 
> </td>
> 
> </ft:repeater-rows>
> 
> </tr>
> 
> </ft:repeater>
> 
> </ft:repeater-rows>
> 
> </table>
> 
> </ft:repeater>
> 
> 
> 
> I had hoped that the submit-on-change styling would force the <td> to re-render with the new
> style, but it doesn't; the ajax update is empty. Is there a way to force the <td> to re-render?

The behaviour you get is expected one because only widgets that have changed are rendered again in
Ajax mode. Form model doesn't know that you want to render some bits again because the rendering
bases on widgets value.

Nevertheless there is a way to force rendering of certain widgets. You just must add them using
addWidgetUpdate[1] method. In order to call this method with proper parameter you will need to
implement your own on-change action[2].

I hope that helps.

[1]
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/formmodel/Form.html#addWidgetUpdate(org.apache.cocoon.forms.formmodel.Widget)
[2] http://cocoon.apache.org/2.2/blocks/forms/1.0/479_1_1.html

-- 
Grzegorz Kossakowski
Committer and PMC Member of Apache Cocoon
http://reflectingonthevicissitudes.wordpress.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org