yajra / laravel-datatables-editor

Laravel DataTables Editor Integration.
https://yajrabox.com/docs/laravel-datatables/editor-installation
MIT License
115 stars 14 forks source link

Uncaught TypeError: Cannot read property 'defaults' of undefined #55

Closed thebatclaudio closed 5 months ago

thebatclaudio commented 3 years ago

Summary of problem or feature request

Hello! First of all thank you for your awesome work! I'm trying to follow your tutorial to install Datatables Editor, but I get two errors in my browser console:

Uncaught TypeError: Cannot read property 'defaults' of undefined

Uncaught TypeError: $.fn.dataTable.Editor is not a constructor

The first is related to this line of code:

DataTable.Editor.defaults.display = "bootstrap";

This is my app.js:

window._ = require('lodash');
window.jQuery = window.$ = require('jquery');
window.Popper = require('popper.js').default;

window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

require('bootstrap-italia');
require('datatables.net-bs4');
require('datatables.net-buttons-bs4');
require('datatables.net-select-bs4');
require('datatables.net-editor-bs4');

My trial started today, so I don't think that the problem is the license. Can you help me to understand what's wrong?

System details

yajra commented 3 years ago

Try adding npm i datatables.net-editor. Also, don't forget to add the post install script on package.json

"postinstall": "node ./node_modules/datatables.net-editor/install.js ./path-to/Editor.zip"
thebatclaudio commented 3 years ago

Hi @yajra, I have already added datatables.net-editor in my package.json and the postinstall script, but I have the same problem. I'm using yarn instead of npm, do you think that it can cause some issues?

thebatclaudio commented 3 years ago

I give you an update: I removed require('datatables.net-editor-bs4'); from app.js and added this in blade file:

    <script src="{{ asset('vendor/datatables/dataTables.editor.min.js') }}"></script>
    <script src="{{ asset('vendor/datatables/editor.bootstrap4.min.js') }}"></script>

Now it works, but I would prefer to include the editor with a require in app.js...

I will do some tests again and if I find a solution I will write it here. Let me know if you find something too.

Thank you

DanielMartinez4290 commented 9 months ago

Hello, The bundle javascript code was not refreshing locally and needed a cache clear which is why these errors showed up after my testing. I fixed all the 404s. Only issue now is sorting out the order of javascript files needed to run datatables.

Screen Shot 2023-11-28 at 1 33 50 PM
github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 5 months ago

This issue was closed because it has been inactive for 7 days since being marked as stale.