I have a div, which is a pretty big form. Maybe 20 fields.
I use this form to create a new user and edit an existing one. I have a user search, and if you click on any result in the result list, it will display this form. Point, I use it a lot and in several places.
My questions - what is the best strategy to manage this?
My first idea was to create a form and hide it when the page loads. Then add it to where I need it and show it. But then it became very difficult when I tried to use an empty container containing this form, since I would never be able to use it again.
So, I tried to create a global variable: var MY_FORM = $("#MyForm"); And just use .append(MY_FORM) whenever I need it, but that didn't work.
Then I thought about using .html() to replicate the form, wherever I needed. But it is very difficult with replicated identifiers. .button() requires me to use a label that needs the a attribute, which depends on the button id attribute, which will be duplicated by multiple instances of the form.
My last thought was to simply create the form where it might be needed, and just show it when the time came.
As you can see, I am in a lot of conflict, and my head hurts, and still 8 AM where I am ...: - (
Any help is much appreciated, thanks!
PS if you can think of a better title, feel free to change it.