我正在尝试创建一个组件,如果给定以下 tml:
<t:slideout>
<p:header>Short Description of Data</p:header>
Long Details about the data here
</t:slideout>
这应该最初在 header 参数中呈现块,当单击此块时,我希望使用 jQuery .slideDown() 函数或等效函数滑出长详细信息部分。
目前我有以下课程:
public class slideout
{
@Parameter(name="header", defaultPrefix = BindingConstants.LITERAL)
private Block headerBlock;
public Block getHeader()
{
return headerBlock;
}
}
和相应的 slideout.tml 文件:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
xmlns:p="tapestry:parameter">
<body>
<t:delegate to="header"/>
<t:body/>
</body>
</html>
我们已经在使用 Tapestry5-jQuery 库,这个组件需要能够在同一个页面上多次使用,所以我也不确定如何确保在渲染页面时没有 ID 冲突。
我不知道从哪里开始,如果我在原始 HTML/jQuery 中这样做,我会做类似的事情
$('slideout-header').click(function() {
$(this).next('slideout-body').slideDown();
});
但是我不确定构建这些类的“Tapestry”方式是什么。在 Tapestry 5 中解决这个问题的最佳方法是什么?