> Inside test.js, I used jQuery, but an error show up telling that jQuery is
> not recognized. But if I change User class to reimport jQuery the problem
> solved.


The problem sounds like the order your scripts are getting included.
When you add the import to your page it moves the jquery import before
test.js.

You might be able to use a JavaScriptStack to solve it
(http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/javascript/JavaScriptStack.html).

This thread might also help:

http://tapestry.1045711.n5.nabble.com/Javascript-include-order-td2436634.html

Instead of using the annotation use RenderSupport.addScriptLink() in
an AfterRender handler to ensure that jquery get's imported first...

Josh

On Sat, Jul 16, 2011 at 8:01 AM, Rendy Tapestry
<rendy.tapes...@gmail.com> wrote:
> Hi All,
>
> I am using tapestry layout component, in page class I add @Import annotation
> to import jquery library. I have another page that is being used along with
> the layout component and having @Import annotation to import specific
> javascript for that page. That javascript used jquery inside it, the problem
> is, jQuery() is not recognized in that script. Solution I have right now, is
> reimport the same jquery library in the page class, every time I need
> jquery. In my opinion that is bothersome.
>
> Here is the detail :
>
> @Import(library = "context:javascript/jquery-1.6.2.min.js")
> public class Layout
> {
> ...
> }
>
>
> and
> @Import(library = "context:javascript/test.js")
> public class User
> {
> ...
> }
>
> Inside test.js, I used jQuery, but an error show up telling that jQuery is
> not recognized. But if I change User class to reimport jQuery the problem
> solved.
>
> @Import(library = {"context:javascript/jquery-1.6.2.min.js",
> "context:javascript/test.js"})
> public class User
> {
> ...
> }
>
> Any suggestion please ?
>
>
> Thanks,
> Rendy.
>

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

Reply via email to