Why click events are not working in defaultContent?
Why click events are not working in defaultContent?

"columnDefs": [
{
"targets": [ -1 ],
"data":"id",
"defaultContent" : '<a href="#" id="delete" data-tax="'+tax+'"
class="btn btn-outline-danger"
@click=deleteTaxGroup(tax_group)>
<i class="fas fa-trash"></i></a>'
}
]
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi @madusanka ,
As
columns.defaultContent
says, it's for static data andcolumns.render
should be used for dynamic.Cheers,
Colin
Here are a couple examples of how to create buttons:
Uses
columns.defaultContent
:http://live.datatables.net/xijecupo/1/edit
Uses
columns.render
:http://live.datatables.net/qemodapi/1/edit
These events seem to work better than the DOM0 events you are trying to use. Also note that you have
id="delete"
. This will assign the same ID to multiple elements. This won[t work as the ID is to be unique on the page.Kevin
Thank you @colin and @kthorngren