Saad Saad - 3 years ago 198
Javascript Question

VueJS Jquery Datatable Integration: Attach method to dynamic html element

I integrated Jquery Datatables with VueJS Here is my Code

I want to attach a method of my Vue compoenent to the

button
My Button
:

row.push('<button @click="vm.buttonPressed()">My Button</button>'); //Add a method when button is pressed


How would I do that?

Answer Source

Have you ever tried building your table using Vue v-for directive for rendering the rows and then just invoking DataTable method on the resulting table?

That would be:

  1. Build your table and rows as you would normally do by using Vue components.
  2. Create a "DataTable" from it like so: $('#example').DataTable();

Take a look at this modified version I made from yours:

https://codepen.io/feload/pen/PJKoJP?editors=1010

Good luck!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download