GWT:如何使用UIBinder将小工具嵌入到Anchor中 [英] GWT: how to embed widgets in Anchor with UIBinder
本文介绍了GWT:如何使用UIBinder将小工具嵌入到Anchor中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在UIBinder中使用以下内容,这样我就可以以编程方式在代码中设置链接的 href
。
I'd like to use the following in UIBinder, so that I can programmatically set the href
of the link in my code.
<g:HTMLPanel>
<g:Anchor ui:field="link">
<g:InlineLabel ui:field="firstName"/>
<g:InlineLabel ui:field="lastName"/>
</g:Anchor>
</g:HTMLPanel>
当我尝试这个时,我得到:
When I try this I get:
ERROR: Found widget in an HTML context Element <g:InlineLabel ui:field='firstName'> (:7).
如何将小部件嵌入到锚中?以前我使用过:
How can I embed widgets inside an anchor? Previously I've resorted to using:
<a id="myAnchor">
etc...
</a>
然后在我的代码中操作DOM来设置HREF,但这很丑。有没有更好的方法?
And then manipulating the DOM in my code to set the HREF, but that's ugly. Is there a better way?
推荐答案
最好使用Panel(流或水平)并将点击处理程序添加到面板模拟一个链接。锚点,按钮和类似的小部件不会允许其中的子标签。
It is better to use a Panel (Flow or Horizontal) and add click handlers to the panel to simulate a link. Anchor, Button and similar widgets will not allow child tags inside them.
这篇关于GWT:如何使用UIBinder将小工具嵌入到Anchor中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文