Skip to content

Commit

Permalink
refactor(Cards) auto init unitialized cards materializecss#565
Browse files Browse the repository at this point in the history
  • Loading branch information
gselderslaghs committed Jan 2, 2025
1 parent abeb249 commit daa30a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,15 @@ export class Cards extends Component<CardsOptions> implements Openable {
}
this._removeRevealCloseEventHandlers();
};

static Init() {
if (typeof document !== 'undefined')
// Handle initialization of static cards.
document.addEventListener('DOMContentLoaded', () => {
const cards = document.querySelectorAll('.card');
cards.forEach((el) => {
if (el && (el['M_Card'] == undefined)) this.init((el as HTMLElement));
});
});
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,4 @@ Forms.Init();
Chips.Init();
Waves.Init();
Range.Init();
Cards.Init();

0 comments on commit daa30a0

Please sign in to comment.