-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught TypeError: Cannot set properties of undefined (setting 'BootstrapTable') #7167
Uncaught TypeError: Cannot set properties of undefined (setting 'BootstrapTable') #7167
Comments
UP |
Try to find a solution for my problem This still a bug for me until someone have any idea. |
You can check out our webpack starter example: https://github.com/wenzhixin/bootstrap-table-examples/tree/develop/webpack-starter. |
I also think this is a bug. Had the exact same error "Uncaught TypeError: Cannot set properties of undefined (setting 'BootstrapTable')", but with some different stack. I just figured out how to make it work after quite some hours struggling yesterday. I'm using: I'm using vite.config.js to inject jquery, so I had this (which is NOT working after build):
and in the '.js' file which is using bootstrap-table, I had the standard imports:
This is working OK if I run 'npm run dev' BUT when I was building the project using 'npm run build', I started to get this "Uncaught TypeError: Cannot set properties of undefined (setting 'BootstrapTable')" error. Solution for me was
from the 'vite.config.js'
To resume, my 'vite.config.js' is now like this:
And my main.js:
And NO other 'bootstrap' imports in my '.js' file. edit: I also tried to inject bootstrap in vite.config.js, but this was not working either. |
Have you solved your problem? |
Same problem for me with Webpack |
Same here. Version 1.21.2 is working for me but not the current one. Thanks @ahmedtoolapp for the hint! |
@trandbert37 @dpoerschke @ahmedtoolapp |
Check your imports.
it worked for me on a plane html-template |
Fixed in the examples repo with updated bootstrap and webpack to the latest version: https://github.com/wenzhixin/bootstrap-table-examples/pull/535/files |
Bootstraptable version(s) affected
1.22.2
Description
Hello,
I'm used to using this plugin, but this time I'm stuck on the first use.
I installed latest version of jQuery 3.7.1 and latest version of Bootstrap 5.3.2 and latest version of Bootstrap-table 1.22.2
All this in a new symfony 6 project with a new installation of webpack 5.74.0, node v21.1.0 and npm
in my app.js file I did:
const $ = require('jquery');
require('bootstrap');
import 'bootstrap-table/dist/bootstrap-table.js';
import 'bootstrap-table/dist/locale/bootstrap-table-fr-FR.js';
and in my js file
const table = $("#table");
Table.bootstrapTable(....)
First thing I got the message
Uncaught TypeError: Cannot set properties of undefined (setting 'BootstrapTable')
I tried to modify how to import jQuery and bootstrap
import jQuery from 'jquery'
window.jQuery = jQuery
window.bootstrap = require('bootstrap');
Unfortunately it doesn't change anything, I tried to use the cdn directly in the base html file, I no longer have the error but in the js file where I declare the table I have the message:
bootstrap is not a function
any ideas why it doesn't work please
Example(s)
app.js
const $ = require('jquery');
require('bootstrap');
import 'bootstrap-table/dist/bootstrap-table.js';
`import 'bootstrap-table/dist/locale/bootstrap-table-fr-FR.js';
file.js
const table = $("#table");
const data = [ { 'id': 0, 'name': 'Item 0', 'price': '$0' }, { 'id': 1, 'name': 'Item 1', 'price': '$1' }, { 'id': 2, 'name': 'Item 2', 'price': '$2' }, { 'id': 3, 'name': 'Item 3', 'price': '$3' }, { 'id': 4, 'name': 'Item 4', 'price': '$4' }, { 'id': 5, 'name': 'Item 5', 'price': '$5' } ]
table.bootstrapTable({data: data})
`
Possible Solutions
No response
Additional Context
Symfony 6 / php 8.2.15
"webpack": "^5.74.0",
symfony/webpack-encore": "^4.5.0"
bootstrap": "^5.3.2"
bootstrap-table": "^1.22.2",
jquery": "^3.7.1",
Node : v21.1.0
npm 10.2.0
The text was updated successfully, but these errors were encountered: