Skip to content

Use event delegation #3

@Rincewind3d

Description

@Rincewind3d

drooltip is currently not usable in a SPA, where HTML is added dynamically after drooltip is initialized.

If you would use a event delegation (e.G. from the body) instead of adding the events on each element this issue would be fixed.

Event Delegation is very easy:

document.querySelector('body').addEventListener("click", function(e) {
	if (e.target.matches(".myTooltip")) {
		// do stuff
	}
});

And don't forget to add a polyfill for element.matches :-) (for IE11)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions