Magento 2.3: How To Initialize Js…?
-
03-03-2021 - |
Question
I'm new to Magento 2.3, I was trying to apply jQuery DataTable and it's done, after that, I want to add it's Button Extention, for that i need to add two more js,so i initialize it, now i'm getting error in my console, Here is my code:
/EC/Downloads/view/adminhtml/requirejs-config.js
var config = {
map: {
'*': {
dataTables: 'EC_Downloads/js/datatables.min'
}
}
};
/EC/Downloads/view/adminhtml/templates/test.phtml
<script>
require(['jquery', 'jquery/ui','dataTables'], function($){
$(document).ready(function($){
$('#example').DataTable({
dom: 'Bfrtip',
buttons: [
'print'
]
});
});
});
</script>
Initializing other two js button.js
, button_print.js
like this:
These Js
files are located in:
/EC/Downloads/view/adminhtml/web/js/buttons.js
/EC/Downloads/view/adminhtml/web/js/buttons_print.js
<script type="text/x-magento-init">
{
"*": {
"EC_Downloads/js/buttons":{},
"EC_Downloads/js/buttons_print":{}
}
}
</script>
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange