You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by rosecorp <ro...@gmail.com> on 2012/09/20 23:18:13 UTC
Preload js after block update
Hi Guys,
I have a block element in tml which contains other components with heavy js
content. Is it possible to pre-load those java script files before zone
update?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Preload-js-after-block-update-tp5716410.html
Sent from the Tapestry - User 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: Preload js after block update
Posted by rosecorp <ro...@gmail.com>.
Thank you Ivan, that suggestion is very useful, I will try to refactor my
solutions this night. Thanks a lot!
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Preload-js-after-block-update-tp5716410p5716427.html
Sent from the Tapestry - User 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: Preload js after block update
Posted by Ivan Khalopik <ik...@gmail.com>.
If you need to load all scripts when page is loaded just place @Import
annotation to your page java class. There is no way to make it dynamicly as
components placed in block are not rendered and as result doesn't add their
scripts to page. You need to specify all scripts explicitly.
Or you can try to create your own hack that will render your block and then
remove it:
public class DirtyHack {
@Parameter(required = true, defaultPrefix = BindingConstants.BLOCK)
private Block block;
@Mixin
private DiscardBody discardBody;
private Element element;
@BeginRender
Object begin(final MarkupWriter writer) {
element = writer.element("placeholder");
return block;
}
@AfterRender
void end(final MarkupWriter writer) {
writer.end();
element.remove();
}
}
<t:dirtyhack block="myBlock"/>
<t:block id="myBlock">
...
</t:block/>
But I not recommend this hack as it will render all hidden components
markup for every page request. Just specify all scrips in page @Import
explicitly.
On Fri, Sep 21, 2012 at 11:18 AM, rosecorp <ro...@gmail.com>wrote:
> Hi Thiago,
>
> Maybe I wasn't clear in my first post. I will paraphrase my problem.
>
> I am using tapestry5-jquery and there is a use case where I load page with
> 3
> different options to choose which are event links and then I handle it in
> java code to render particular block. The problem is that one of those
> blocks contain several of complicated component like file upload,
> accordions
> etc. and I see in Firebug that all js are being loaded after ajax call
> which
> is not very nice for user experience. At the moment I have sorted this
> problem basically to load those components once page has been loaded in a
> hidden div and then after ajax call I will show up those hidden divs but I
> think this solutions is nasty. Is there any better way to do this?
>
> Thanks in advance and sorry for a long explanation.
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Preload-js-after-block-update-tp5716410p5716425.html
> Sent from the Tapestry - User 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
>
>
--
BR
Ivan
Re: Preload js after block update
Posted by rosecorp <ro...@gmail.com>.
Hi Thiago,
Maybe I wasn't clear in my first post. I will paraphrase my problem.
I am using tapestry5-jquery and there is a use case where I load page with 3
different options to choose which are event links and then I handle it in
java code to render particular block. The problem is that one of those
blocks contain several of complicated component like file upload, accordions
etc. and I see in Firebug that all js are being loaded after ajax call which
is not very nice for user experience. At the moment I have sorted this
problem basically to load those components once page has been loaded in a
hidden div and then after ajax call I will show up those hidden divs but I
think this solutions is nasty. Is there any better way to do this?
Thanks in advance and sorry for a long explanation.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Preload-js-after-block-update-tp5716410p5716425.html
Sent from the Tapestry - User 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: Preload js after block update
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 20 Sep 2012 18:18:13 -0300, rosecorp
<ro...@gmail.com> wrote:
> Hi Guys,
Hi!
> I have a block element in tml which contains other components with heavy
> js content. Is it possible to pre-load those java script files before
> zone
> update?
Why don't you just use @Import to load these JavaScript files? You know
you're going to use them anyway . . .
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Preload js after block update
Posted by rosecorp <ro...@gmail.com>.
Thank to both of you guys! It's great to have that excellent support from you
guys. Thanks again!
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Preload-js-after-block-update-tp5716410p5716434.html
Sent from the Tapestry - User 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