Shared varible in Template Repeater

#1

Hi,
I was wondering if it is possible to have a shared varible between instances of templates when using Template Repeater?
In my case I have created a button in a template with lable-name as input. I have then used Template Repeater to create x number of buttons. When a button is clicked I want to save the lable-name in a shared varible which I can use to know which button that was last clicked.

0 Likes

#2

Create a client tag and write to that?

0 Likes

#3

You can also .parent up a few levels until you’re at the template repeater itself.

Just try with a number of .parent, and print the type of the result to see where you are.

print 1, type(event.source.parent)
print 2, type(event.source.parent.parent)
print 3, type(event.source.parent.parent.parent)
print 4, type(event.source.parent.parent.parent.parent)
print 5, type(event.source.parent.parent.parent.parent.parent)
2 Likes

#4

Thank you!
I actually tried that before but I used .name instead of type() and got ‘None’ as result.
I see now that I did not go far enough in the hierarchy. I now get this result when using
…parent.name:

1 Button
2 Template_button
3 None
4 None
5 None
6 Template Repeater
7 Root Container

(It was the ‘None’-result that confused me.)

Thank you very much for the answer!

0 Likes