Copy link to clipboard
Copied
I'm working on a form that has several templates which are spawned via buttons when required. I also am adding a button to reset the form and delete the spawned pages (so pages 12 to the end). The templates will be hidden, but I have them unhidden for now so that I can edit them. But when I test my reset button, it deletes the entire template. I assume this is because when it is unhidden, it IS page 12 and when it is hidden it is page -1 and the spawned page becomes page 12.
So do I just need to keep hiding and unhiding my template to test it or is there a more efficient method for editing when templates are involved?
You'll need to add a condition to your code that checks whether the template page is hidden before deleting those pages. If not, it means it's the actual Template page itself and you shouldn't delete it. You can set the code to hide it, instead.
If the template is page 12 when un-hidden, and the delete script deletes pages 12 to the end, then yes, it follows that the template page would be deleted. I would suggest creating a button to toggle the visibility of your templates to make testing easier. This button can then be deleted or hidden for the final form.
Copy link to clipboard
Copied
You'll need to add a condition to your code that checks whether the template page is hidden before deleting those pages. If not, it means it's the actual Template page itself and you shouldn't delete it. You can set the code to hide it, instead.
Copy link to clipboard
Copied
Probably the best solution for the end product.
Copy link to clipboard
Copied
If the template is page 12 when un-hidden, and the delete script deletes pages 12 to the end, then yes, it follows that the template page would be deleted. I would suggest creating a button to toggle the visibility of your templates to make testing easier. This button can then be deleted or hidden for the final form.
Copy link to clipboard
Copied
That seems like a logical workaround. Just wasn't sure if there was something I was missing about working with templates.
Copy link to clipboard
Copied
You are not missing anything. Templates are only ever visible for development. During normal use they should always be hidden.