From cae3467e0fd85da88a144a6ce872fa78f26a7b10 Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Tue, 27 May 2025 15:03:52 -0700 Subject: [PATCH] added `GridStack.updateCB(w)` * gets called after a widget has been updated (eg: load() after initial layout) instead of created --- doc/CHANGES.md | 8 ++++++-- src/gridstack.ts | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 0072066ef..c3e445dda 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -5,7 +5,8 @@ Change log **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) @@ -127,7 +128,10 @@ Change log -## 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 diff --git a/src/gridstack.ts b/src/gridstack.ts index 726296ade..1a63d73cd 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -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' */ @@ -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 }); return this;