I am including datatable plugin to my custom module.
I tried in this way, below is the code of my Vendor/Module/view/frontend/requirejs-config.js
var config = {
map: {
'*': {
dataTables: 'Vendor_Module/js/datatables.min'
}
}
};
including css file like below in Vendor/Module/view/frontend/layout/default.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Vendor_Module::css/datatables.min.css"/>
</head>
And i moved my css and js files into respective folders inside web folder. Vendor/Module/view/frontend/web/css/datatables.min.css Vendor/Module/view/frontend/web/js/datatables.min.js
I have used below code in my template file to load Datatable.
<script>
require(['jquery', 'jquery/ui','dataTables'], function($){
$(document).ready(function($){
$('#example').DataTable();
});
});
seems datatable is not loading. and getting below error in console.
Uncaught Error: Script error for: jquery
Please anyone suggest me where i am wrong. Thanks