cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martijn C. Vos" <>
Subject RE: Ajax Event & Javascript
Date Tue, 27 Jun 2006 08:45:27 GMT

Nicolas Duroc [] wrote:

> I have a repeater in a table to build the rows. I use an "add-row" button with AJAX,
and a "delete-rows",
> all works fine, but I tried to use "dojo drag'n drop" ( dojo). When I use the AJAX buttons,
dojo doesn't
> work anymore. I think the problem comes from the init() function of dojo, which is not
reloaded when a row
> is added. I would like so, to catch the "add-row" event, and execute the init() function.

> I tried with a <fd:on-action> control and a <javascript> part, but it shows
an "indefined document" error,
> I can't direct access to the document page, is there a way to access it ? or another
way to catch the AJAX
> event ? 

I'm not familiar with dojo, but I may have got a solution for you.
It's not the pretiest, because it involves changing the
cocoon-ajax.js loaded by the browser.

In my forms-custom-styling, I've put this matcher:

  <xsl:template match="bu:replace[fi:output/fi:styling/@iframe]">
    <bu:iframeupdate id="fundframe" src="{fi:output/fi:styling/@iframe}?{fi:output/fi:value}"/>

This checks if a certain element is being updated (in my case,
an output widget that uses custom styling to turn into an
iframe, in your case the repeater), and then, instead of
sending an 'bu:replace' ajax event to the browser, I send my
own custom event, bu:iframeupdate, which I'll catch in the
cocoon-ajax.js to trigger the javascript I want to trigger.

In your case, you still want to update the repeater, and I'm
not entirely sure if you can send two events in a single
response, so you'll have to check that. If that's not
possible, you may be able to change the cocoon-ajax.js to
deal with multiple events. Or not, I really don't know that
much about it.

In any case, in cocoon-ajax.js, search for
cocoon.ajax.BrowserUpdater.handlers = {
    replace :  function(element) {

Change this to:
cocoon.ajax.BrowserUpdater.handlers = {
    replace :  function(element) {
    yourevent : function(element) {
[your javascript]

That did the job for me.

It would be nice if cocoon-ajax supported easier creation of
custom eventhandlers, preferably in the form-definition.xml,
but if necessary in the form-template or the custom-styling.
But that's probably an issue for the dev list.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message