全局使用以下JavaScript代碼它在每個網頁自動插在我的web應用程序:如何覆蓋JavaScript屬性
<script type="text/javascript">
$(document).ready(function() {
$('#cemetracDataTable').dataTable({
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "http://fubar.com/wp-content/TableTools-2.1.5/media/swf/copy_csv_xls_pdf.swf",
"aButtons": [
"copy",
"print",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [
{
"sExtends": "csv",
"sButtonText": "Excel (CSV)",
"bFooter": false,
"sTitle": "My title",
"sFileName": "download.csv" // <-- override
},
{
"sExtends": "xls",
"sButtonText": "Excel (TSV)",
"bFooter": false,
"sFileName": "download.tsv" // <-- override
},
{
"sExtends": "pdf",
"bFooter": false,
"sFileName": "download.pdf" // <-- override
}
]
}
]
}
}).columnFilter();
});
</script>
我希望能夠到特定網頁例如: -
...
"sFileName": "widgets.csv"
...
"sFileName": "widgets.tsv"
...
"sFileName": "widgets.pdf"
正在這樣做可能對overrride的sFileName屬性?如果是這樣,這將如何完成?
我m不知道如何在'dataTable'方法中獲得對傳入對象的引用,所以,會是bett呃如果將它分配給一個變量,然後將該變量作爲參數傳遞給'dataTable'方法。 '$('#cemetracDataTable')。dataTable(myObj)' – Givi