Preventing dialog() from rearranging DOM flow

Preventing dialog() from rearranging DOM flow

I'm a fairly new to jQuery and the world of Javascript in general, so bear with me please.

I have a form that will be used only via touch-screen, so checkboxes/radio buttons are all hidden and checked and unchecked via clicks on their respective labels. That works great. The problem that has surfaced is I am putting "sub-options" in a div which is then being initiated as a dialog on page load and taking those checkboxes and radio buttons out of the form element because jQuery puts the dialog elements at the very bottom of the page.

The relevant javascript looks like this right now :
  1. //setup modal boxes for list type amenities
  2. $('div.options').dialog({
  3. autoOpen:false,
  4. modal:true,
  5. resizable:false,
  6. show: 'slide',
  7. hide: 'slide',
  8. });
  9. $('label.list').click(function(){
  10. $('div#'+$(this).attr('rel')).dialog('open');
  11. });
  12. $('.hidden_radio').change(function(){
  13. if($(this).attr('checked') == true){
  14. $(this).parent().css('background-color','#fff');
  15. $(this).parent().siblings('li').css('background-color','transparent').css('color','#000');
  16. $(this).siblings(':first').css('color','#000');
  17. }
  18. else{
  19. $(this).parent().css('background-color','#800');
  20. $(this).siblings(':first').css('color','#fff');
  21. }
  22. $(this).parents('div.options').dialog('close');
  23. console.log($(this).parents('div.options').attr('id'));
  24. $('label[rel='+$(this).parents('div.options').attr('id')+']').css('color','#000')
  25. .parent().css('background-color','#fff');
  26. }); 

And the DOM looks like this (BEFORE dialog() is called) :

  1. <form>
  2. <!-- other inputs -->
  3. <li class='nav amen'> 
  4.     <label class='list' rel='option22'>Complex</label> 
  5.     <div id="option22" class="options"> 
  6.         <ul> 
  7.     <li> 
  8. <label for='amen[22][0]'>Blossom Hollow</label> 
  9. <input type='radio'
  10. name='amen[22]'
  11. id='amen[22][0]'
  12. value='Blossom Hollow'
  13. class='hidden_radio' /> 
  14.     </li> 
  15.     <li> 
  16.                 <label for='amen[22][1]'>Bird's Eye View</label> 
  17.                 <input type='radio'
  18.                  name='amen[22]'
  19.                  id='amen[22][1]'
  20.                          value='Bird&#039;s Eye View'
  21.                  class='hidden_radio' /> 
  22.             </li> 
  23. </ul> 
  24.     </div> 
  25. </li> 
  26. </form>
But when I call dialog() on 'div.options', it moves those divs down to the bottom of the DOM outside of the form and those inputs no longer get submitted with the post data.

The 'easy' solution in my mind is to force jQuery to attach those divs to some parent element inside the form, but I can't find any option to pass to do that, and I'm not sure if that might somehow interfere with how jQuery handles the display and hiding of the dialog windows.

The other solution I've thought of is to keep the form elements outside of the 'div.options' so they stay inside the form and only the labels get moved out.. I don't think that'd mess up the activation of the elements with my previously mentioned jQuery, but the php on the backend will be a mess.

Thoughts/other solutions? Thanks much.