You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Fabrizio Sitzia <fa...@chem.lu> on 2006/01/16 11:32:30 UTC

Ajax multivaluefield/double-listbox problem

Hello

I'm experiencing problems when rendering a multivaluefield using the
'double-listbox' styling - when that multivaluefield is contained in a
repeater, and Ajax is enabled for the form (ft:form-template ajax="true")

The 'double-listbox'-styled fields in the repeater stop working as soon as
some action, involving a round-trip to the server and a partial
re-rendering of the repeater, is being performed (for example adding or
deleting a repeater row)
After such a round-trip, a click on any of the double-listbox's UI
elements (double-click on an item, click on an option-transfer button)
will yield the Javascript error "optNxxxxx is not defined".

The form works fine if Ajax is disabled, or if a styling other than
'double-listbox' is used for rendering the multivaluefields (default
styling as a multiple-selection list, or list-type='checkbox' styling)

Has somebody out there experienced this problem, or even better, come with
a fix for it?


I would like to keep Ajax enabled - especially as it avoids the 'jump to
top-of-page' effect when adding or deleting rows on lengthy forms. And I
would like to also keep the 'double-listbox', simply because to most users
they are a lot more intuitive to use than html's default
multiple-selection boxes, and less noisy than a bunch of checkboxes.


BTW: The Cocoon version I'm using is 2.1.8
The problem does not appear to be browser-specific (same behaviour with
IE6 on Windows, Firefox on both Windows and OSX, Safari on OSX)


Fabrizio


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


Re: Ajax multivaluefield/double-listbox problem

Posted by Fabrizio Sitzia <fa...@chem.lu>.
Hello,

I tried using the latest Ajax and Forms block from the BRANCH_2_1_X svn
branch. The issue appears to have been partially fixed, but the
double-listbox styling still won't work in combination with repeaters and
Ajax.

I've now reported that issue, and a crude, Cocoon 2.1.8 specific fix, on
JIRA:

  http://issues.apache.org/jira/browse/COCOON-1738


Best regards,
Fabrizio


> Hi Fabrizio,
>
> I did some fixes in the AJAX block after 2.1.8 release, can you try to
> from the lastest SVN code and report back if the issue is already fixed?
>
> Best Regards,
>
> Antonio Gallardo.
>
> Fabrizio Sitzia wrote:
>
>>Hello,
>>
>>I've digged a bit in the source myself ...and found out two things:
>>
>>1. The "optNxxxxx is not defined" Javascript error is apparently caused
>> by
>>the optNxxxxx variable being initialised in a local scope instead of the
>>document's global scope.
>>( For non-IE browsers, this can be fixed by replacing the line containing
>>"eval(scripts[i]);" in cocoon-ajax.js with "setTimeout(scripts[i], 10);"
>> )
>>
>>
>>2. But even if the optNxxxxx variable is initialised all right, you will
>>stumble upon other stuff not being initialised correctly:
>>
>>The 'double-listbox' widget relies on an object (OptionTransfer) that is
>>normally initialised by a document onLoad() handler.
>>That is fine for full page reloads, but with partial updates via Ajax,
>> the
>>onLoad() handler for a freshly added 'double-listbox' widget is never
>>going to be executed!
>>
>>
>>I've looked at the bug report you mention below (COCOON-1718), and have
>>merged the changes to my 'cocoon-ajax.js' file, but it doesn't appear to
>>fix the global var-, nor the onLoad- issues with the 'double-listbox'
>>widget.
>>
>>
>>I'm currently working on a fix, tbc.
>>
>>Thanks for your reply,
>>Fabrizio
>>
>>
>>
>>
>>>Looking at the source, I believe this is due to the fact that
>>><script></script> contents received via AJAX requests are executed
>>>before they are added to the main page's DOM, not after.  The styling
>>>for double-listbox includes a snippet of script that calls a global
>>>function to hook up event listeners etc., and this fails because at the
>>>time it is run the elements aren't yet part of the document.
>>>
>>>There is a bug report in Jira [1] about scripts being run too soon;
>>>someone attached a preliminary approach for a fix but it seems there are
>>>still issues with it.  Not sure if that helps or not.
>>>
>>>[1] http://issues.apache.org/jira/browse/COCOON-1718
>>>


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


Re: Ajax multivaluefield/double-listbox problem

Posted by Antonio Gallardo <ag...@agssa.net>.
Hi Fabrizio,

I did some fixes in the AJAX block after 2.1.8 release, can you try to 
from the lastest SVN code and report back if the issue is already fixed?

Best Regards,

Antonio Gallardo.

Fabrizio Sitzia wrote:

>Hello,
>
>I've digged a bit in the source myself ...and found out two things:
>
>1. The "optNxxxxx is not defined" Javascript error is apparently caused by
>the optNxxxxx variable being initialised in a local scope instead of the
>document's global scope.
>( For non-IE browsers, this can be fixed by replacing the line containing
>"eval(scripts[i]);" in cocoon-ajax.js with "setTimeout(scripts[i], 10);" )
>
>
>2. But even if the optNxxxxx variable is initialised all right, you will
>stumble upon other stuff not being initialised correctly:
>
>The 'double-listbox' widget relies on an object (OptionTransfer) that is
>normally initialised by a document onLoad() handler.
>That is fine for full page reloads, but with partial updates via Ajax, the
>onLoad() handler for a freshly added 'double-listbox' widget is never
>going to be executed!
>
>
>I've looked at the bug report you mention below (COCOON-1718), and have
>merged the changes to my 'cocoon-ajax.js' file, but it doesn't appear to
>fix the global var-, nor the onLoad- issues with the 'double-listbox'
>widget.
>
>
>I'm currently working on a fix, tbc.
>
>Thanks for your reply,
>Fabrizio
>
>
>  
>
>>Looking at the source, I believe this is due to the fact that
>><script></script> contents received via AJAX requests are executed
>>before they are added to the main page's DOM, not after.  The styling
>>for double-listbox includes a snippet of script that calls a global
>>function to hook up event listeners etc., and this fails because at the
>>time it is run the elements aren't yet part of the document.
>>
>>There is a bug report in Jira [1] about scripts being run too soon;
>>someone attached a preliminary approach for a fix but it seems there are
>>still issues with it.  Not sure if that helps or not.
>>
>>[1] http://issues.apache.org/jira/browse/COCOON-1718
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>  
>


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


Re: Ajax multivaluefield/double-listbox problem

Posted by Fabrizio Sitzia <fa...@chem.lu>.
Hello,

I've digged a bit in the source myself ...and found out two things:

1. The "optNxxxxx is not defined" Javascript error is apparently caused by
the optNxxxxx variable being initialised in a local scope instead of the
document's global scope.
( For non-IE browsers, this can be fixed by replacing the line containing
"eval(scripts[i]);" in cocoon-ajax.js with "setTimeout(scripts[i], 10);" )


2. But even if the optNxxxxx variable is initialised all right, you will
stumble upon other stuff not being initialised correctly:

The 'double-listbox' widget relies on an object (OptionTransfer) that is
normally initialised by a document onLoad() handler.
That is fine for full page reloads, but with partial updates via Ajax, the
onLoad() handler for a freshly added 'double-listbox' widget is never
going to be executed!


I've looked at the bug report you mention below (COCOON-1718), and have
merged the changes to my 'cocoon-ajax.js' file, but it doesn't appear to
fix the global var-, nor the onLoad- issues with the 'double-listbox'
widget.


I'm currently working on a fix, tbc.

Thanks for your reply,
Fabrizio


> Looking at the source, I believe this is due to the fact that
> <script></script> contents received via AJAX requests are executed
> before they are added to the main page's DOM, not after.  The styling
> for double-listbox includes a snippet of script that calls a global
> function to hook up event listeners etc., and this fails because at the
> time it is run the elements aren't yet part of the document.
>
> There is a bug report in Jira [1] about scripts being run too soon;
> someone attached a preliminary approach for a fix but it seems there are
> still issues with it.  Not sure if that helps or not.
>
> [1] http://issues.apache.org/jira/browse/COCOON-1718



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


Re: Ajax multivaluefield/double-listbox problem

Posted by Jason Johnston <co...@lojjic.net>.
Fabrizio Sitzia wrote:
> Hello
> 
> I'm experiencing problems when rendering a multivaluefield using the
> 'double-listbox' styling - when that multivaluefield is contained in a
> repeater, and Ajax is enabled for the form (ft:form-template ajax="true")
> 
> The 'double-listbox'-styled fields in the repeater stop working as soon as
> some action, involving a round-trip to the server and a partial
> re-rendering of the repeater, is being performed (for example adding or
> deleting a repeater row)
> After such a round-trip, a click on any of the double-listbox's UI
> elements (double-click on an item, click on an option-transfer button)
> will yield the Javascript error "optNxxxxx is not defined".
> 
> The form works fine if Ajax is disabled, or if a styling other than
> 'double-listbox' is used for rendering the multivaluefields (default
> styling as a multiple-selection list, or list-type='checkbox' styling)
> 
> Has somebody out there experienced this problem, or even better, come with
> a fix for it?
> 
> 
> I would like to keep Ajax enabled - especially as it avoids the 'jump to
> top-of-page' effect when adding or deleting rows on lengthy forms. And I
> would like to also keep the 'double-listbox', simply because to most users
> they are a lot more intuitive to use than html's default
> multiple-selection boxes, and less noisy than a bunch of checkboxes.
> 
> 
> BTW: The Cocoon version I'm using is 2.1.8
> The problem does not appear to be browser-specific (same behaviour with
> IE6 on Windows, Firefox on both Windows and OSX, Safari on OSX)

Looking at the source, I believe this is due to the fact that 
<script></script> contents received via AJAX requests are executed 
before they are added to the main page's DOM, not after.  The styling 
for double-listbox includes a snippet of script that calls a global 
function to hook up event listeners etc., and this fails because at the 
time it is run the elements aren't yet part of the document.

There is a bug report in Jira [1] about scripts being run too soon; 
someone attached a preliminary approach for a fix but it seems there are 
still issues with it.  Not sure if that helps or not.

[1] http://issues.apache.org/jira/browse/COCOON-1718



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