Radio Buttons and Cloning
Hey,
I'm trying to clone a section of code that contains radio buttons.
I'd like the original section & the cloned section to be in different
radio button groups. However, this doesn't seem to be happening with
jQuery cloning. I've reduced my code as much as possible to test out
the scenario, the code is below. For note, I've tried both the
method
below (clone, change properties, add to page) as well as the reverse
(clone, add to page, change properties).
Is there a reason this doesn't work? Is this a bug in jQuery? Is
this just not possible in browsers?
$("#testRadio1").val("bloop1");
$("#testRadio2").val("bloop2");
$("[name='testRadio']").click(function(event) {
alert($(this).attr('id') + "[" + $(this).attr('name') + "]: "
+ $(this).val());
});
$("#testRadio1").clone(true).attr('id', 'testRadio3').attr('name',
'testRadioB').val("bloop3").insertBefore($("#formCreateService"));
$("#testRadio2").clone(true).attr('id', 'testRadio4').attr('name',
'testRadioB').val("bloop4").insertBefore($("#formCreateService"));
Thanks!
Jamie Goodfellow