Miguel Flores Miguel Flores - 7 months ago 63
Javascript Question

Execute a function from dynamic button

I'm creating a table, after that I convert table to jQuery dataTable, for this I'm using

and an option to display information in a modal, problem here is that my function button is only displayed on the modal, so my question is what can I do to access to that button, I'm trying doing this but do not work.

$('#TableBody').on('click', '.glyphicon-edit', function () {

This do not work too:

//example is my table id
$('#example').on('click', '.glyphicon-edit', function () {

Here is my full code to see my problem properly.


If you're using Bootstrap styling, use the code below. This will narrow your selector to the element in the modal opened by jQuery DataTables.

$(document).on('click', '.dtr-bs-modal .glyphicon-edit', function(){
   // ... skipped ...