I have this simple wrap, bind to onClick
HTML
<button class="button secondary" onclick="editButton(this)">Edit</button>
JQuery
function editButton(edit) {
var row = $(edit).closest('.row'),
cells = row.children().toArray(),
i=0,
inputName = "",
inputValue = "",
html = "";
cells.pop(); // remove control cell
for(i; i<cells.length; i++) {
inputName = $(cells[i]).attr('data-name');
inputValue = $(cells[i]).attr('data-value');
html = "<input type='text' name='"+inputName+"' value='"+inputValue+"'>";
$(cells[i]).html(html);
}
$(row).wrap('<form action="/action_page.php" method="post"></form>');
$(row).wrap('<div class="test"></div>'); //this works!
}
instead of wrapping the dom, the page refresh to action_page.php