Lift:使用 CSS 转换为每个项目创建 AJAX 超链接
我想创建一个项目列表,并在每个项目上都有一个执行某些操作的超链接,例如从列表中删除该项目。
我的模板如下所示:
<lift:surround with="default" at="content">
<div class="locations lift:Main.locations">
<ul>
<li class="one">
<span class="name">Neverland</span>
(<a href="#" class="delete">delete this</a>)
</li>
</ul>
</div>
</lift:surround>
我正在使用以下 CSS 转换来填写它:
def locations = {
".one *" #> somecollection map { item =>
".name" #> item.name &
".delete" #> ????
}
}
现在,我不想添加“????”,而是按照 SHtml.a( ( )=>delete(item), _)
,但是这里的 _
是 CssSel
类型,并且 a
的参数应该是 NodeSeq
我可以当然,放置简单的 xml.Text("delete this")
,但我想重用模板内的文本。
或者有其他方法来生成 AJAX 超链接吗?
I want to create a list of items and have a hyperlink on each of them that performs some action, e.g. remove the item from the list.
My template looks like this:
<lift:surround with="default" at="content">
<div class="locations lift:Main.locations">
<ul>
<li class="one">
<span class="name">Neverland</span>
(<a href="#" class="delete">delete this</a>)
</li>
</ul>
</div>
</lift:surround>
I'm using the following CSS transform to fill it out:
def locations = {
".one *" #> somecollection map { item =>
".name" #> item.name &
".delete" #> ????
}
}
Now, instead of "????", I'd love to put in something along the lines of SHtml.a( ()=>delete(item), _)
, but _
here is of type CssSel
and a
's argument should be NodeSeq
I could of course put simple xml.Text("delete this")
, but I want to reuse the text that is inside the template.
Or is there a different way to generate AJAX hyperlinks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道怎么做了。基本上,我必须使用模板中的标签并通过 CSS 转换将 AJAX 代码放入其中,而不是生成
a
标签:我怀疑这种方式也可以建立链接无论有没有 JavaScript 都可以工作
I found out how to do it. Basically, instead of generating the
a
tag, I have to use the tag from the template and put the AJAX code in it through the CSS transform:I suspect that this way it would also be possible to make links that work both with and without JavaScript