Jquery Mobile - jQM generated DIVs are cloning on AJAX post return

Jquery Mobile - jQM generated DIVs are cloning on AJAX post return


I have several pages that submit a form via AJAX post in a jQuery Mobile Application (using v1.4), and I cannot get around this problem to save my life.

The form is filled out, the user presses button (not submit input, but button), and the following code handles it:

  1. $('#edit_admin_btn').click(function() {
  2.       var valid = $("#edit_admin_user_form").valid();

  3.       if(valid){
  4.             $.post("admin.php?a=vendors&v=users&x=update" , $("#edit_admin_user_form").serialize(), function(data) {
  5.                   if(data == 1){ //success
  6.                         $("html, body").animate({ scrollTop: 0 }, "slow");
  7.                         $('.update-msg').html('Profile Updated Successfully!').delay(5000).fadeOut();

  8.                   } else { //fail
  9.                         $('<div>').simpledialog2( {
  10.                               mode: 'blank',
  11.                               headerClose: true,
  12.                               forceInput: false,
  13.                               themeDialog: 'a',
  14.                               themeHeader: 'a',
  15.                               themeButtonDefault: 'a',
  16.                               blankContent: '<div class="ui-content">'+data+'</div>'
  17.                         });
  18.                   }
  19.             });
  20.             }
  21.             });

The problem is, when the reposonse comes back, all of the input fields clone within themselves on the page (I have tried removing the simple dialog and the jquery validation to make sure it didn't cause the efffect). Upon inspecting the page in firebug, I see that the div wrapper around the input field that is created by jQM is cloned inside of itself. I cannot find a fix for this. The form itself has no submit button, no action and no method. This button handles all of that, as you can see in the code above. (if it helps, this cloning affect is also occuring on collapsibles on the page as well -- possibly on all div wrappers generated by jQM).

Any help would be greatly appreciated.