Ui template script lost after switch of tab

Take a look at this thread and see if it helps