Skip to content

Commit 3c930db

Browse files
committed
refactor(Cards) auto init unitialized cards #565
1 parent 6da7599 commit 3c930db

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/cards.ts

+11
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,15 @@ export class Cards extends Component<CardsOptions> implements Openable {
173173
}
174174
this._removeRevealCloseEventHandlers();
175175
};
176+
177+
static Init() {
178+
if (typeof document !== 'undefined')
179+
// Handle initialization of static cards.
180+
document.addEventListener('DOMContentLoaded', () => {
181+
const cards = document.querySelectorAll('.card');
182+
cards.forEach((el) => {
183+
if (el && (el['M_Card'] == undefined)) this.init((el as HTMLElement));
184+
});
185+
});
186+
}
176187
}

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,4 @@ Forms.Init();
138138
Chips.Init();
139139
Waves.Init();
140140
Range.Init();
141+
Cards.Init();

0 commit comments

Comments
 (0)