Editor with edit icon not working
Editor with edit icon not working
asle
Posts: 96Questions: 28Answers: 0
I am working on implementing my own data from this example:
https://editor.datatables.net/examples/inline-editing/editIcon.html
Here is my page.
https://wilfavarmepumpe.no/demo/Editor-PHP-2.0.7/examples/simple/simple_wilfa.html
The problem is that the edit icon shows but nothing happens when I click on the icon. It seems the <I> element is not triggering a click for the .on() function for "td I" element.
This question has accepted answers - jump to:
Answers
I solved it ( I think). In the example it says:
I changed it to
It seems it could not find the <I> with the first code. Strange?
More likely there wasn't a
tbody
element, for the#example
table, in the DOM to attach the event listener to at the time the above statement was executed. Glad you got it working.Kevin
Thanks. Yes there is a
tbody
tag on the table. Like the example I only wrote thethead
section and datatables should create the rest, correct?Yes, Datatables will build the
tbody
. You are loading Datatables viaajax
which asynchronous. The$('#example tbody').on( 'click',...
is executed before the Ajax response meaning thetbody
hasn't been added by Datatables yet.EDIT: Just to add if you have anything that needs to run after Datatables init is complete use the
initComplete
option.Kevin
I understand now! Thanks so much for even more enlightenment on DataTables!