Guys, I have sorted my cards using
<<for>>
Here how I did it:
[How to find generic object in array and return something]
But I’ve faced another problem.
Now I need those cards to be clickable, and on click a variable should be set as a copy of the clicked card’s parameters.
It wasnt a problem to make it clickable, but I still cant save parameters of the card in the variable.
Here’s my code:
<<set $routinecards.sort((a,b) => {
return a.id - b.id})>>
<<for _i=0;_i < $routinecards.length;_i++>>
<a data-passage="dayplan" data-setter="$dawn to $routinecards[_i]">
<img @src='"img/cards/"+ $routinecards[_i].type + "/" + $routinecards[_i].id + ".png"' style="position:relative; left:0; top:0;" height="`20%" width="20%">
</a>
<</for>>
StoryInit:
<<set $s1 to {class: "routine", type: "s", id: 1}>>
<<set $n2 to {class: "routine", type: "n", id: 2}>>
<<set $routinecards to [$n2, $s1]>>
The problem is 100% here:
data-setter="$dawn to $routinecards[_i]"
I think maybe it doesn’t work because click happens after the cycle already created. So, maybe I just cant use this “for” method to reach the goal.
Maybe someone can help me to fix this, or teach me a better option