Wicket 1.5 Javascript File in Body Tag

后端 未结 1 1138
花落未央
花落未央 2021-01-14 05:19

I need to put a script-tag inside the body, because the javascript doesn\'t work in the head tag.

As of Wicket 1.5 the following code is not longer supported:

<
相关标签:
1条回答
  • 2021-01-14 05:56

    Have you tried using a urlFor with a resource reference? Something like..

    script.add(new AttributeAppender("src", urlFor(new JavaScriptResourceReference(BaseTemplate.class, "wz_tooltip.js"), null).toString())); 
    

    I wouldn't expect your current method to work out of the box because of Wicket's complex resource management. Also, while there may be other "right" ways to do things, I've often found that 3rd-Party javascript can be finicky about placement and I still need to fall back on this method for some scripts.

    For example, one script I use must be the last element on the page.

    0 讨论(0)
提交回复
热议问题