OK - I'm halfway through now (I think so, at least) :-) 

I believe that I need to "hook" into the Tapestry.ZONE_UPDATED_EVENT event
when my t:zone is updated with the t:block containing the form - this is
what I do: 

Event.observe('zoneTest', Tapestry.ZONE_UPDATED_EVENT, function()
{
        alert('zone updated');
});

This is working for me now that I've updated the app from T5.0.18 to
T5.1.0.5. The issue is - even in this even handler, I can't get a hold of my
form element. It doesn't seem to exist in the document tree. When I try to
do Event.observe('myForm', 'submit', function() {......} ); Unlike before,
I'm not getting any JS errors (even if I provide an invalid ID for the form
such as 'myForm123'), but even using document.getElementById will only
return null for 'myForm'.

Any ideas?

Thanks,
Rado 




immutability wrote:
> 
> A little background: I need to wire-up some custom JavaScript to be
> launched when the Submit button of my form is clicked. I now believe that
> the best way to do this with Tapestry5 is to use the Event.observer for
> this purpose. Unfortunately my knowledge of client-side javascript,
> scriptaculous, etc, is limited, and I can't make this work. The issue
> seems to be that my form is within a t:block that gets injected into a
> t:zone dynamically.
> 
> So, even if I do this in my JS file:
> 
> Event.observe(window, 'load', function() 
> {
>       Event.observe('formTranslator', 'submit', function() 
>       {
>           // some onsubmit actions
>       });
> });
> 
> this will fail, because apparently, the my form named formTranslator
> doesn't exist at the point the document is loaded (the form gets
> reinjected into the t:zone whenever a new object to translate is selected
> by the user). The JavaScript error that I see in my JS console is this:
> 
> "element is null" -> scriptaculous/prototype.js Line:3936
> 
> I guess I somehow need to have the Event.observer called everytime the
> form is reinjected into the t:zone, but how? Are my assumptions correct at
> all?
> 
> Thanks for any ideas in advance!
> 
> Rado
> 

-- 
View this message in context: 
http://old.nabble.com/T5%3A-Using-Event.observer-with-a-form-within-a-t%3Ablock-tp28697334p28707025.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to