[英]Toggle Display of Only Nearest Element in Aurelia
I could easily do this with vanilla JS or jQuery but wondering what the "correct" way to simply achieve the following is in Aurelia. 我可以使用香草JS或jQuery轻松地做到这一点,但想知道在Aurelia中简单地实现以下目标的“正确”方法是什么?
I have a ton of "cards" with toggle buttons to show that cards "hidden-info". 我有很多带有切换按钮的“卡片”,以显示该卡片为“隐藏信息”。 With the way that I'm currently doing it, clicking any "expand-toggle" display all cards "hidden-info".
按照我目前的操作方式,单击任何“展开-切换”将显示所有卡“隐藏信息”。
What is the right way to toggle only the nearest sibling with Aurelia? 用Aurelia仅切换最近的兄弟姐妹的正确方法是什么?
Here's my example.html
: 这是我的
example.html
:
<div class="inner">
<i class="expand-toggle" click.delegate="expandCard()"></i>
<h3>Title</h3>
<div if.bind="cardExpanded" class="au-animate hidden-info">
</div>
</div>
And my example.js
: 和我的
example.js
:
export class Example {
constructor() {
this.cardExpanded = false;
}
expandCard() {
this.cardExpanded = true;
}
}
Also, how would I then hide it on the next click. 另外,在下次单击时如何将其隐藏。 This is basic but I am new to Aurelia.
这是基本知识,但我是Aurelia的新手。 Thanks!
谢谢!
I would try 我会尝试
example.html: example.html的:
<div class="inner">
<i class="expand-toggle" click.delegate="expandCard(this)"></i>
<h3>Title</h3>
<div if.bind="cardExpanded" class="au-animate hidden-info">
</div>
</div>
example.js: example.js:
export class Example {
constructor() {
this.cardExpanded = false;
}
expandCard(sender) {
sender.cardExpanded = !sender.cardExpanded;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.