Skip to content
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

Cookie extension throws a JS error #7670

Open
designdisorder opened this issue Dec 30, 2024 · 4 comments
Open

Cookie extension throws a JS error #7670

designdisorder opened this issue Dec 30, 2024 · 4 comments
Labels
Bug Issues which are marked as Bug

Comments

@designdisorder
Copy link

Bootstraptable version(s) affected

1.24.0

Description

I get the following JS error after upgrading to the latest 1.24.0 release. The issue is caused by the cookie extension, which obviously contains some changes in the latest release. Switching back to the previous 1.23.5 version of the cookie extension, everything works as before.

jQuery.Deferred exception: undefined is not an object (evaluating 'this.options.cookieExpire') "@https://unpkg.com/[email protected]/dist/extensions/cookie/bootstrap-table-cookie.min.js:10:46389 value@https://unpkg.com/[email protected]/dist/extensions/cookie/bootstrap-table-cookie.min.js:10:41930 @https://unpkg.com/[email protected]/dist/bootstrap-table.min.js:10:142452 forEach@[native code] value@https://unpkg.com/[email protected]/dist/bootstrap-table.min.js:10:142423 @https://unpkg.com/[email protected]/dist/bootstrap-table.min.js:10:155464 each@https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js:2:3133 @https://unpkg.com/[email protected]/dist/bootstrap-table.min.js:10:155275 @http://127.0.0.1:52122/energy/:742:36 dispatch@https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js:2:40040 trigger@https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js:2:70129 @https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js:2:70733 each@https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js:2:3133 value@https://unpkg.com/[email protected]/dist/bootstrap-table.min.js:10:130241 value@https://unpkg.com/[email protected]/dist/bootstrap-table.min.js:10:122097 @https://unpkg.com/[email protected]/dist/extensions/group-by-v2/bootstrap-table-group-by.min.js:10:27908 value@https://unpkg.com/[email protected]/dist/bootstrap-table.min.js:10:86007 value@https://unpkg.com/[email protected]/dist/extensions/key-events/bootstrap-table-key-events.min.js:10:24684 value@https://unpkg.com/[email protected]/dist/extensions/cookie/bootstrap-table-cookie.min.js:10:39283 @https://unpkg.com/[email protected]/dist/bootstrap-table.min.js:10:155731 each@https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js:2:3133 @https://unpkg.com/[email protected]/dist/bootstrap-table.min.js:10:155275 @https://unpkg.com/[email protected]/dist/bootstrap-table.min.js:10:156160 e@https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js:2:27033 @https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js:2:27331" undefined

Example(s)

No online example available at this point

Possible Solutions

Not a solution yet. Workaround: using the 1.23.5 version of the cookie extension

Additional Context

No response

@designdisorder designdisorder added the Bug Issues which are marked as Bug label Dec 30, 2024
@designdisorder
Copy link
Author

I did some more tests with some of the features I use in the specific example where this happens. This is what I found:
I use some code to hide individual columns below a certain screen breakpoint. I'll do that during table generation as well as a window resize. When I use this code the cookie extension throws the error above. If I don't use this code, everything is fine like in the previous version 1.23.5.

Here is the code that hides specific columns at a given breakpoint:

$table.on('pre-body.bs.table', () => {
	const width = $(window).width()
	if (width < 576) {
		$table.bootstrapTable('hideColumn', 'stacks_in_56_cons')
	} else {
		$table.bootstrapTable('showColumn', 'stacks_in_56_cons')
	}
})

$(window).on('resize', () => {
	const width = $(window).width()
	if (width < 576) {
		$table.bootstrapTable('hideColumn', 'stacks_in_56_cons')
	} else {
		$table.bootstrapTable('showColumn', 'stacks_in_56_cons')
	}
})

It looks like that the cookie extension somehow has a problem with the bootstrapTable('showColumn', ...) and bootstrapTable('hideColumn', ...) calls. I'll try to create a pure BST example based on that finding.

@designdisorder designdisorder changed the title Cookie extension generates JS error Cookie extension throws a JS error Dec 30, 2024
@designdisorder
Copy link
Author

If I remove 'bs.table.hiddenColumns' in data-cookies-enabled, no error occurs

@wenzhixin
Copy link
Owner

Please provide an Online Example to show your problem. Thanks!

@simonsolutions
Copy link

Hi, i have the same issue with the version 1.24.0.

`; expires=${UtilsCookie.calculateExpiration(this.options.cookieExpire)}`,

In this line the "this.options" is undefined, so that "this.options.cookieExpire" can not be read

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues which are marked as Bug
Projects
None yet
Development

No branches or pull requests

3 participants