still me with the same deal..
So i'll explain it quick. I've all includes in my page so thats not it.
I'm working on visual studio.
I've created a table that i want to export in pdf or anything else. And so i'm using this :
https://github.com/hhurz/tableExport.jquery.plugin
This works very well if in my code i put it like this :
$('table').tableExport({ type: 'pdf', jspdf: { orientation: 'l', format: 'a3', margins: { left: 10, right: 10, top: 20, bottom: 20 }, autotable: { styles: { fillColor: 'inherit', textColor: 'inherit' }, tableWidth: 'auto' } } });
Obviously surrounded by balise.
But anytime i want to put this in a button, it doesn't work !! Chrome console keep saying me this : .tableExport is not a function
How can it be possible ? It works well when i just call the script !
This is my event and my button (please if someone has something to help that would be really great !) :
$(document).ready(function () {
$('#downloadPDF').on('click', function (e) {
console.log("test");
e.preventDefault();
$('table').tableExport({ type: 'csv' });
$('table').tableExport({
type: 'pdf',
jspdf: {
orientation: 'l',
format: 'a3',
margins: {
left: 10,
right: 10,
top: 20,
bottom: 20
},
autotable: {
styles: {
fillColor: 'inherit',
textColor: 'inherit'
},
tableWidth: 'auto'
}
}
});
});
});
<button type="button" id="downloadPDF" class="btn btn-default">Default</button>*@
Thanks guys.
<table id="table" class="table table-hover ">
<tbody>
<tr>
<td></td>
<td> </td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
<tr class="info">
<td><b></b></td>
<td></td>
</tr>
<tbody>
<tr>
<td>
<br /><br />
<br /><br />
<br /><br />
</tbody>
</td>
<td><br /><br /><br /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td> </td>
</tr>
<tr>
<td></td>
<td> </td>
</tr>
</tbody>
</table>
</div>
@* Bouton extraction *@
<script>
$(document).ready(function () {
});
</script>
<script>
$('#downloadPDF').on('click', function (e) {
console.log("test");
e.preventDefault();
$('table').tableExport({
type: 'pdf',
jspdf: {
orientation: 'l',
format: 'a3',
margins: {
left: 10,
right: 10,
top: 20,
bottom: 20
},
autotable: {
styles: {
fillColor: 'inherit',
textColor: 'inherit'
},
tableWidth: 'auto'
}
}
});
});
</script>
<button type="button" id="downloadPDF" class="btn btn-default">Default</button>*@