Copying a button with the underlying functionality

I have a button with about 15 blocks of code under it.

I would like to copy that button with its underlying functionality to a different screen.

Is it possible to do that?

Mike

1 Like

hi @mdsmith1

I know from my own experience components with event handlers will get all of them copied using just Ctrl+C/Ctrl+V, but not sure if that didn't work when you tried it?

If I may offer advice, I find it more maintainable to write the logic in a script query or transformer, and then trigger the query (or rely on state updates for transformers, no triggering) from the button.

Yes, I did try Ctrl+C/Ctrl+V. That just copies the button but not the code underneath it.
.
Could you explain this again using different words. I can't quite grasp what you are trying to say.

Mike

hi @mdsmith1

gotcha yeah let me elaborate. two things:

  1. when i copy and paste a button with scripts (onSubmit event handlers to trigger queries, or to run JS), the scripts get copied too.
  1. it ends up being easier to manage and organize a list of scripts and queries that are triggered by (and reference) components, than to stuff a bunch of logic into the components themselves