cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <>
Subject Re: Repost from users list: Cforms Repeater - Cancel delete action via javascript
Date Tue, 30 Aug 2005 08:18:05 GMT
Christoph Hermann wrote:

>i originally posted this question on the users list some time ago, but
>nobody did respond. After some discussion on freenode/#cocoon i decided
>to mail the dev list.
>So i'm asking you: Is there a way to cancel a repeaters delete-row
>action in case a certain condition is met?
>I tried to put a javascript "return false;" in the on-action, but this
>throws an error. (Invalid return)
>I think there should be a simple way to prevent the action to be
>performed, but i did not find anything in the docs. In the docs there is
>only mentionned that the on-action is performed before the delete-row.
>What i basically want to do is disable the deleting of rows that are
>still referenced somewhere. I.e. you have two xml documents which
>reference each other and you cannot delete a "parent"-row if there are
>still "children" in another document referencing this element.
>I'd be very happy if someone of you could help me with this.

Hmm... the delete-row action accepts additional listeners, but those are 
not supposed to be able to cancel the action. The "Invalid return" error 
you get is because the on-action is a script snippet that has no return 

To achieve what you want, you should use a plain action widget with an 
on-action that surrounds the row deletion with the filtering logic.

Deleting a row is rather straightforward, and here's the code behind the 
delete-row widget:

    Repeater.RepeaterRow row = 
    Repeater repeater = (Repeater)row.getParent();

Which translates to JS as:

    var row = 
    var repeater = row.parent;


Sylvain Wallez                        Anyware Technologies
Apache Software Foundation Member     Research & Technology Director

View raw message