Excel button get Uncaught TypeError: this.each is not a function
Excel button get Uncaught TypeError: this.each is not a function
rognales
Posts: 8Questions: 3Answers: 1
My Excel button throws this error jquery.dataTables-1.10.19.min.js:83 Uncaught TypeError: this.each is not a function
No issue on CSV button.
FYI, i use requireJS.
<script type="application/javascript">
require(['jquery','datatables.net','datatables.net-bootstrap4','jszip','datatables.net-buttons','datatables.net-buttons-html5','datatables.net-buttons-flash'], function($, JSZip) {
window.JSZip = JSZip;
$(document).ready(function() {
var table = $('table#market').DataTable({
dom: 'Bflrtip',
buttons: [ { extend: 'excel', text:'<i class="fa fa-file-excel-o"></i> Save as Excel', titleAttr:'Excel', className: 'btn btn-default btn-sm', }, ],
});
});
});
</script>
Config uploaded by debug tools --> https://debug.datatables.net/eqehas
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Does the error identify which
each
call in Buttons is causing the issue? Can you link to the page showing the issue, as it appears to work okay here?Thanks,
Allan
Hi Allen, thx for responding.
I solved the issue.
Actually the jszip is the one throwing the error.
Referring to line 3 (in original post), the JSZip namespace is not available. The assigning does nothing.
This is the solution. the namespace returned should matched with the require order.
jquery -> $
jszip -> JSZip
How do i mark this as closed?
Its done now