This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Wouter Duijts
Posted Aug 16 - Read on Facebook

Hi guys,

I'm a bit stuck on a project.
I have two pages whereby I have a list of cards on the second page with information loaded by an external file.
On selecting a card I want the information from it to be displayed on the first page. I managed to get the information on the first page but not by the correct index.
What to do?

See attached project. ± line 169

Thanks in advance!

2 Comments

Derek Nguyen

Ah, the coffeescript hiccup. If you're doing event inside your `for..` loop, wrap them in a `do` function:

```
for i in [0..10]
--do (i) ->
----# your other usual stuffs
----# ...
----fabricSelection.text = fabricTitle[i]
```

otherwise the generated javascript function will only receive the last `i` in the loop, which is 10.

"When using a JavaScript loop to generate functions, it’s common to insert a closure wrapper in order to ensure that loop variables are closed over, and all the generated functions don’t just share the final values. CoffeeScript provides the do keyword, which immediately invokes a passed function, forwarding any arguments."
http://coffeescript.org/

edit: add link to coffeescript doc

Wouter Duijts

Works like a charm! Thanks!
I'm going to read more about how and why of this to fully understand.

Read the entire post on Facebook