laravel-datatables-editor icon indicating copy to clipboard operation
laravel-datatables-editor copied to clipboard

Uncaught TypeError: Cannot read property 'defaults' of undefined

Open thebatclaudio opened this issue 4 years ago • 3 comments

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

  • Operating System: Windows 10
  • PHP Version: PHP 7.4.11 (cli) (built: Sep 29 2020 13:17:42) ( NTS Visual C++ 2017 x64 )
  • Laravel Version: 6.20.3
  • Laravel-DataTables Version: 1.5.0
  • Laravel-DataTables-Editor Version: 1.22.0

thebatclaudio avatar Dec 17 '20 17:12 thebatclaudio

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"

yajra avatar Dec 18 '20 02:12 yajra

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 avatar Dec 18 '20 14:12 thebatclaudio

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

thebatclaudio avatar Dec 18 '20 15:12 thebatclaudio

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

DanielMartinez4290 avatar Nov 28 '23 21:11 DanielMartinez4290

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] avatar Mar 17 '24 00:03 github-actions[bot]

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

github-actions[bot] avatar Mar 24 '24 00:03 github-actions[bot]