Skip to content

Any reason for not being able to prevent auto initialization of HSTooltip? #402

Answered by langscot
sebz asked this question in Q&A
Discussion options

You must be logged in to vote

Seems like the HSTooltip's autoInit method does not exclude elements with --prevent-on-load-initclass.

	static autoInit() {
		if (!window.$hsTooltipCollection) window.$hsTooltipCollection = [];

		document.querySelectorAll('.hs-tooltip').forEach((el: HTMLElement) => {
			if (
				!window.$hsTooltipCollection.find(
					(elC) => (elC?.element?.el as HTMLElement) === el,
				)
			)
				new HSTooltip(el);
		});
	}

This should be an open issue, I can't think why it wouldn't respect --prevent-on-load-init since as far as I'm aware the other plugins do.

As a workaround, you could not autoInit the tooltip collection and do this yourself somewhere in your code:

document.querySelectorAll('.hs-tool…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sebz
Comment options

Answer selected by sebz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants