jquery - invoke javascript on button click of a datatable row -


im using datatable , have following:

 var otable = $('#example').datatable({                  bprocessing: true,                 sajaxsource: "/cart/addresses",                 'idisplaylength': 5,                 aasorting: [],                 aocolumns: [                     { "mdata": "contact" },                     { "mdata": "address" },                     { "mdata": "postcode" },                     {                         "mdata": null,                         "mrender": function (data, type, full) {                             return '<button type="button" class="btn btn-success use-address" onclick="dofunction();" role="button" data-adcode="' + full.adcode + '">' + 'use address' + '</button>';                         }                     }                  ]             }); 

i have tried following, want bale use adcode when button clicked:

 $('.use-address').click(function () {         var adccode = $(this).data("adcode");      });      function dofunction()     {         var adccode = $(this).data("adcode");      } 

this wont work, in firebug doesnt hit either of these.

note datatable added dynamically (after clicking button.)

any ideas why aint working?

thanks

try use event delegation here:

$('#example').on('click','.use-address',function () {     var adccode = $(this).data("adcode"); }); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -