Skip to content

Instantly share code, notes, and snippets.

@sonOfRa
Last active December 25, 2015 11:08
Show Gist options
  • Save sonOfRa/6966202 to your computer and use it in GitHub Desktop.
Save sonOfRa/6966202 to your computer and use it in GitHub Desktop.
/**
* Unmerge the specified <td> element
* @param td td to unmerge
*/
function unmerge(td) {
var colspan = td.attr("colspan");
td.attr("colspan", 1);
var id = td.attr("id").split("x");
for (var i = colspan - 1; i > 0; i--) {
var tdclass = td.attr("class");
var tdid = id[0] + "x" + (parseInt(id[1]) + i);
var div = td.children().first();
var divclass = div.attr("class");
var divcontent = div.text();
var newTD = "<td class=\"" + tdclass + "\" colspan=\"" + 1 + "\" id=\"" + tdid + "\">" +
"<div class=\"" + divclass + "\">" +
divcontent +
"</div>" +
"</td>";
console.log(newTD);
td.after(newTD);
$("#" + tdid).droppable(timetableDroppable);
$("#" + tdid).children().click(onclick).draggable({
revert: true
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment