Render add return multiple DOM items without dummy parent
Render add return multiple DOM items without dummy parent
Preface: this question is not urgent. Since the issue can easily be sidestepped. I am just curious. ^^
I am currently adding an 'Add' Row button to a table. As a result I had to move the rendering from the backend to the frontend via the render.
The table in question had column with three buttons which were direct children of the <td>-cell.
original hierarchy:
<td><button id=1/><button id=2/><button id=3/></td>
hierarchy after switching to column.render function:
<td>< div id=parent><button id=1/><button id=2/><button id=3/></div></td>
I was curious if there was a way to preserve the original structure using the render function.
Returning the buttons in an array:
return [document.createElement("button"), document.createElement("button"), document.createElement("button")]
resulted in
<td>[object HTMLButtonElement],[object HTMLButtonElement],[object HTMLButtonElement]</td>
Turning the HTMLButtonElemen objects into strings via outerHTML and cococatenating these strings results in the correct structure, but onclick handlers are lost.
https://live.datatables.net/yokegoxe/36/edit.
And that's about where I ran out of ideas. ^^
with kind regards,
Flo