Insert Extensions Link in seperate javascript file
Insert Extensions Link in seperate javascript file
Hello,
i have some datatables on my asp.net core mvp website. To store the javascript-code outside, i created an .js file with all javascript code for the tables. but for some extensions(e.g. colReorder, Buttons) i need to add a link for the datatables script to the html site. The link is generated by the download builder. but if i just copy it to my html file with the javascript in my external javascript file, it doesn´t work. only if i put all the javascript-code into the html file, than it works....
I hope some can understand my problem
Answers
Happy to take a look into it if you post a link to the page showing the issue.
Allan
The proper way to do this is probably to add the javascript files to a bundle and then loading the bundle on the .cshtml pages that you want it.
In App_Start\BundleConfig.cs:
And then load the bundle on the desired page like this:
My .cshtml file:
<table id="dataTable" class="table table-responsive table-striped table-hover" cellspacing="0" width="100%">
And this is how I refer to the javascript:
<script src="~/js/ordersLocation.js"></script>
This are the links, generated by downloadbuilder:
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jqc-1.12.4/dt-1.10.13/b-1.2.4/b-colvis-1.2.4/cr-1.3.2/datatables.min.css" />
The second link:
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/jqc-1.12.4/dt-1.10.13/b-1.2.4/b-colvis-1.2.4/cr-1.3.2/datatables.min.js"></script>
This is the script I need for the table:
$('#dataTablea').DataTable({ autoWidth: true, dom: 'Bfrtip', colReorder: true, bStateSave: true, buttons: [ { extend: 'colvis', columns: ':not(:first-child)', text: 'Spalten anzeigen' } ] });Oh my god....just tried it at IE and it works fine, only chrome brokes it...
Without a page showing the issue, there is honestly little help we can provide since there is no way to debug it.
Allan
Can be closed....