私は今朝から大きな問題に直面しています。私はテーブルをpdfファイルにエクスポートしようとしています。私が何もせずにそれを置くと、スクリプトはうまく動作し、ページの読み込みとdlが始まります。未知のタイプエラーを取得する:私がボタンで私の.tableExportを使用しようとすると
しかし、私はボタンでそれをしたい!私はこのようにそれを置くときと:
$(document).ready(function() {
$('#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'
}
}
});
});
});
<button type="button" id="downloadPDF" class="btn btn-default">Default</button>
私はクロームコンソールでこのエラーを取得:
Uncaught TypeError: $(...).tableExport is not a function(anonymous function) @ Auto:290jQuery.event.dispatch @ jquery-1.10.2.js:5109elemData.handle @ jquery-1.10.2.js:4780
私は理由を理解することはできません。イベントに参加していないときはうまく動作するからです。
'$( 'table')'とは何ですか? –
これは私のテーブルのIDです –
それは '$( '#table')' –