1

I have a form in my page where the fields are being populated from ajax like dropdowns. Now I have a added a tab to the page as well. My second tab of the page will contain the same form fields and some additional ones. How do I duplicate my first tab content and load it into the second tab with room for some addition elements to be added on. I have a jsfiddle here.

http://jsfiddle.net/UL9cx/5/

I tried adding it manually and doing show hide for the divs on click of tabs, but for some reason form fields on second tab don't load as I guess ajax is creating issues.

can anybody help me out here.

Thanks,

Mike
  • 3,348
  • 11
  • 45
  • 80
  • could you add the ajax code in your fiddle? what are you doin with what the server returns. what is the server actually returning. – Rooster Dec 17 '11 at 19:16

1 Answers1

1

I'm not sure I totally understand the question, but the following should clear the second block, and append a clone of the first...

$('.block.two').empty().append($('.block:first').clone(true).contents());

Updated jsfiddle here: http://jsfiddle.net/UL9cx/7/

jhoff
  • 716
  • 7
  • 14
  • You don't want to do that: [Why should y.innerHTML = x.innerHTML; be avoided?](http://stackoverflow.com/questions/7392930/why-should-y-innerhtml-x-innerhtml-be-avoided) – Šime Vidas Dec 17 '11 at 21:11
  • 1
    Duly noted... and I've updated it with the answer provided in your reference. – jhoff Dec 17 '11 at 21:17