responsive plugin with require.js
responsive plugin with require.js
rsilva
Posts: 5Questions: 3Answers: 0
I am unable to successfully use the respnsive plugin with require.js.
Here's my require.js config:
require.config({
paths: {
'jquery': 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min',
'datatables': '//cdn.datatables.net/s/dt/dt-1.10.10,r-2.0.0/datatables.min'
}
});
require(['jquery', 'datatables'], function($, datatables){
$(function(){
$('#myTable').DataTable( {
responsive: true
});
});
});
The above config renders the datatables corrrectly, but without the responsive functionality.
Now, if I load the same scripts in the document header, (without require.js) everything works as expected.
<head>
...
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//cdn.datatables.net/s/dt/dt-1.10.10,r-2.0.0/datatables.min.js"></script>
<script src="js/main2.js"></script>
</head>
Has anyone run into this problem? Thank you in advance!
This discussion has been closed.
Answers
The problem is going to be related to the fact that the file you are including from the CDN includes two different AMD modules - DataTables and Responsive.
There are a few SO discussions on this topic which I'll need to look into myself. I haven't used RequireJS at lot myself, so I don't have an immediate answer.
I'll post back here once I get a chance to look into it. Or if you beat me too it, any feedback would be welcome!
Allan