Thanks to visit codestin.com
Credit goes to github.com

Skip to content

added GridStack.updateCB(w) #3061

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

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Change log
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*

- [12.1.2-dev (2024-05-07)](#1212-dev-2024-05-07)
- [12.2.0 (2025-05-27)](#1220-2025-05-27)
- [12.1.2 (2024-05-07)](#1212-2024-05-07)
- [12.1.1 (2024-04-28)](#1211-2024-04-28)
- [12.1.0 (2024-04-23)](#1210-2024-04-23)
- [12.0.0 (2025-04-12)](#1200-2025-04-12)
Expand Down Expand Up @@ -127,7 +128,10 @@ Change log

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## 12.1.2-dev (2024-05-07)
## 12.2.0 (2025-05-27)
* feat: [#3061](https://github.com/gridstack/gridstack.js/pull/3061) added `GridStack.updateCB(w)` that gets called after a widget has been updated (eg: load() after initial layout) instead of created

## 12.1.2 (2024-05-07)
* fix [#3043](https://github.com/gridstack/gridstack.js/issues/3043) fix `opts.animate` again
* fix [#3048](https://github.com/gridstack/gridstack.js/pull/3048) nested grid resizeToContentCBCheck() fix

Expand Down
4 changes: 4 additions & 0 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ export class GridStack {
*/
public static renderCB?: RenderFcn = (el: HTMLElement, w: GridStackNode) => { if (el && w?.content) el.textContent = w.content; };

/** called after a widget has been updated (eg: load() into an existing list of children) so application can do extra work */
public static updateCB?: (w: GridStackNode) => void;

/** callback to use for resizeToContent instead of the built in one */
public static resizeToContentCB?: ResizeToContentFcn;
/** parent class for sizing content. defaults to '.grid-stack-item-content' */
Expand Down Expand Up @@ -1383,6 +1386,7 @@ export class GridStack {
if (ddChanged) {
this.prepareDragDrop(n.el);
}
GridStack.updateCB(n); // call user callback so they know widget got updated
Copy link

@creage creage May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code crashes with TypeError: GridStack.updateCB is not a function

});

return this;
Expand Down