How to create button that allows you to choose between two templates

Hello again.

I have found an effect when executing the button that I am not sure if it is normal or if I am doing something wrong. If I have two buttons, each in an open tiddler, if I activate one the other is activated.

I’m attaching a screenshot to give you a better idea.

Can this be avoided?

All the best.!

Yes :slightly_smiling_face:
The trick is to use the qualify macro to get a unique state tiddler name for each tiddler using the button.
Here is the code: XabrinaExample3.json (5.1 KB).
I included a clone of the example tiddler, for convenience.
You can look for the 3 lines of code containing myState in both example tiddlers.

Fred

1 Like

Hello @tw-FRed.

Now it works completely fine for me with your instructions. :partying_face:

Thank you very much again.

You can also add another parameter such as n to add into the qualification so you can have the same button more than once in the same tiddler, if that is needed.

  • I have done it in the general solution for popups I am developing. It will be available soon, after I resolve a regression, ie I fixed something but the problem came back.

eg <$set name=popup-state value={{{ [<qualify $:/temp/popup>addsuffix<n>] }}}> then use <<popup-state>> where n is a parameter in the procedure/macro.

1 Like

I am filing this under “Things I had no idea I needed until now”. This is awesome. Thanks tw-FRed!