将 AJAX 添加到 wicket:link 内的图像无法正确解析图像 url?
请问,有什么方法可以实现这一目标吗?
- 相对于 html 页面在 HTML 中定义的静态图像,
- 向其添加 AJAX 链接以进行一些 AJAX 操作
,我有这样的:
<wicket:link>
<img src="images/test.jpg">
</wicket:link>
->找到并显示图像,网址自动解析为:
<img src="resources/my.package.MyClass/images/test.jpg" >
第二我添加了 AJAX 操作:
<wicket:link>
<img src="images/test.jpg" wicket:id="sayHelloImage">
</wicket:link>
add(new AjaxLink("sayHelloImage") {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("alert('Hello!')");
}
});
->结果是该操作有效,但图像网址不再解析,找不到图像,网址保持不变: img src="images/test.jpg" ...
我知道我可以从类中动态加载图像,如下所示: ResourceReference image = new ResourceReference(MyClass.class,"images/test.jpg"); 但这是我不想的,我更愿意在html中设置图像url。
谢谢你, 谨致问候,
-约瑟夫-
please, is there a way how to achieve this ?
- static image with url defined in HTML relatively to the html page
- adding the AJAX link to it to make some AJAX action
1st I had this:
<wicket:link>
<img src="images/test.jpg">
</wicket:link>
-> image is found and displayed, the url was automatically resolved to :
<img src="resources/my.package.MyClass/images/test.jpg" >
2nd I added the AJAX action:
<wicket:link>
<img src="images/test.jpg" wicket:id="sayHelloImage">
</wicket:link>
add(new AjaxLink("sayHelloImage") {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("alert('Hello!')");
}
});
-> the result is that the action works, but the image url is no longer resolved, image is not found, the url stayed the same:
img src="images/test.jpg" ...
I know that I can load the image dynamically from the class like this:
ResourceReference image = new ResourceReference(MyClass.class,"images/test.jpg");
but this is what I don't want to, I would prefer to set the image url in html.
Thank you,
with kind regards,
-josef-
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
;不能用于生成链接 (AjaxLink)。
试试这个:
<img> can't be used to produce a link (AjaxLink).
Try this: