You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tim Graf <tm...@googlemail.com> on 2011/05/06 13:01:26 UTC

Execute JavaScript from dynamic component

Hi,

I want to execute some JavaScript code from a component which is dynamically
reloaded within the page. The static component I have had before used the
javaScriptSupport.addScript method for this purpose, but this only works
when the whole page gets reloaded. How can I do the same dynamically? (I
know, it's probalby a stupid question, but I'm a bloody tapestry noob; thank
your for your patience ;-)

-Tim

Re: Execute JavaScript from dynamic component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
This questions keeps appearing the the users mailing list. What's the  
reason JavaScriptSupport isn't added to the environment in AJAX requests?  
This is a pain in the rear . . . :(

On Fri, 06 May 2011 08:01:26 -0300, Tim Graf <tm...@googlemail.com>  
wrote:

> Hi,
>
> I want to execute some JavaScript code from a component which is  
> dynamically
> reloaded within the page. The static component I have had before used the
> javaScriptSupport.addScript method for this purpose, but this only works
> when the whole page gets reloaded. How can I do the same dynamically? (I
> know, it's probalby a stupid question, but I'm a bloody tapestry noob;  
> thank
> your for your patience ;-)
>
> -Tim


-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
Coordenador e professor da Especialização em Engenharia de Software com  
Ênfase em Java da Faculdade Pitágoras
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: Execute JavaScript from dynamic component

Posted by Taha Hafeez <ta...@gmail.com>.
Have a look at Tapestry.loadScriptsInReply() in tapestry.js

regards
Taha

On Fri, May 6, 2011 at 6:23 PM, LLTYK <LL...@mailinator.com> wrote:

> Turn your script into a mixin, that will automatically call the mixin's
> addScript again on partial reloads. I think there was another way to do it
> as well, some other way of calling addScript again, can't recall it though.
>
> --
> View this message in context:
> http://tapestry-users.832.n2.nabble.com/Execute-JavaScript-from-dynamic-component-tp6337184p6337494.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Execute JavaScript from dynamic component

Posted by LLTYK <LL...@mailinator.com>.
Turn your script into a mixin, that will automatically call the mixin's
addScript again on partial reloads. I think there was another way to do it
as well, some other way of calling addScript again, can't recall it though.

--
View this message in context: http://tapestry-users.832.n2.nabble.com/Execute-JavaScript-from-dynamic-component-tp6337184p6337494.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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


Re: Execute JavaScript from dynamic component

Posted by Richard Hill <ri...@su3analytics.com>.
Hi Tim,

A "cheap" way is to simply include your javascript in a <script> tag at
the bottom of your component .tml:

<script type="text/javscript">yourFunctionCall()</script>

This will be executed every time the component is re-rendered.

If you want to add multiple lines, be careful of comments - tapestry
strips out new lines in .tml so a comment // will result in all
subsequent lines being ignored. You can get around this by putting "\n"
to force a new line.

Richard


On Fri, 2011-05-06 at 13:01 +0200, Tim Graf wrote:
> Hi,
> 
> I want to execute some JavaScript code from a component which is dynamically
> reloaded within the page. The static component I have had before used the
> javaScriptSupport.addScript method for this purpose, but this only works
> when the whole page gets reloaded. How can I do the same dynamically? (I
> know, it's probalby a stupid question, but I'm a bloody tapestry noob; thank
> your for your patience ;-)
> 
> -Tim



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