Tapestry 5.2 中是否有一些本地方法可以将 eventLink 转换为按钮
我的问题很简单。我想使用按钮作为事件链接。
tml 中的表单内部存在基于 AJAX 的事件链接。事件链接具有动态更新表单某些部分的功能:
<t:eventlink t:event="editPlace" t:zone="dialogZone" class="jqModal place editPlace"
t:context="placeId">${message:editPlace}</t:eventlink>
我希望 eventLink 成为一个按钮,如下所示:
<t:eventButton t:event="editPlace" t:zone="dialogZone" class="jqModal place editPlace"
t:context="placeId">${message:editPlace}</t:eventButton>
但自然这样的东西不存在。我认为有一些第三方库可以做到这一点,但感觉有点矫枉过正。
我还尝试通过以下方式欺骗 eventLink 用 javascript 触发:
<button type="button" onclick="jQuery(this).next('a').click();">
${message:editPlace}
</button>
<t:eventlink t:event="editPlace" t:zone="dialogZone" class="jqModal place editPlace"
t:context="placeId">${message:editPlace}</t:eventlink>
正确找到了锚点,但不起作用。还有其他选择吗?
编辑:使问题更清楚。
My problem is simple. I want to use button as an event link.
There exists AJAX-based event link inside a form in tml. The event link has functionality that updates some parts of the form dynamically:
<t:eventlink t:event="editPlace" t:zone="dialogZone" class="jqModal place editPlace"
t:context="placeId">${message:editPlace}</t:eventlink>
I would like that eventLink to be a button, something like this:
<t:eventButton t:event="editPlace" t:zone="dialogZone" class="jqModal place editPlace"
t:context="placeId">${message:editPlace}</t:eventButton>
But naturally such thing does not exist. I think there are some 3rd party libraries to do it, but it feels kind of overkill.
I also tried to trick the eventLink to be triggered with javascript in following way:
<button type="button" onclick="jQuery(this).next('a').click();">
${message:editPlace}
</button>
<t:eventlink t:event="editPlace" t:zone="dialogZone" class="jqModal place editPlace"
t:context="placeId">${message:editPlace}</t:eventlink>
The anchor is correctly found but does not work. Are there any other options?
Edit: Made the question more clear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解正确的话,您希望通过单击按钮来更新区域。您不需要任何自定义组件来执行此操作,通常的
Form
、Submit
和Zone
组件就可以了。只需在模板中使用按钮创建一个表单并设置其
zone
参数即可:在页面类文件中,设置事件侦听器来侦听表单提交并返回区域的正文:
瞧!
--编辑:
因此,由于这在其他表单中不起作用,因此我们将尝试其他方法。
click()
的问题在于它不是本机事件,并且不会馈送到 Prototype 的事件管道中。您可以手动触发区域更新,如下所示:If I understand you correctly, you want to update a zone from the click of a button. You won't need any customized components to do this, the usual
Form
,Submit
andZone
components will do just fine.Just create a form with the button in your template and set its
zone
parameter:And in your page class file, you set your event listener to listen to the form submission and return the zone's body:
Ét voilà!
--Edit:
So, as that won't work inside another form, we'll try something else.
The problem with the
click()
is that it is not a native event and does not feed into Prototype's event pipeline. You could instead trigger the zone update manually, like this:您可以在事件链接的主体中嵌套一个按钮。
或者您可以使用 CSS 将链接样式设置为看起来像按钮。例如,如果您使用 twitter-bootstrap 的 CSS,您可以执行以下操作:
You can just nest a button in the body of the eventlink.
Or you can use CSS to style the link to look like a button. For instance if you are using twitter-bootstrap's CSS you could do the following: