Trying to add button dynamically, doing something wrong :(

Trying to add button dynamically, doing something wrong :(

puffsterpuffster Posts: 53Questions: 20Answers: 0

https://jsfiddle.net/w0vpn36y/

No error messages shown

I want to dynamically add buttons and am not having any luck. I've attached the JSFiddle, I thought I did everything as shown in the examples but it just ignores the button.add task :(

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 13,584Questions: 25Answers: 3,197
    Answer ✓

    You are using this to init Datatables:

    var dtab = $('#tblCohort').dataTable({ ... });
    

    The variable dtab doesn't contain the Datatable API instance needed for adding the button. See this FAQ. Use an upper case D, like this:

    var dtab = $('#tblCohort').DataTable({ ... });
    

    Updated example:
    https://jsfiddle.net/myafc10x/

    Kevin

  • puffsterpuffster Posts: 53Questions: 20Answers: 0

    O.M.G. I seriously don't know if I ever would have caught that. Thanks so much!!

Sign In or Register to comment.