Skip to content

Support alpine-typescript component names #173

Answered by stancl
stancl asked this question in Ideas
Discussion options

You must be logged in to vote

This seems like the best solution:

import { AlpineComponent } from '@leanadmin/alpine-typescript';

window.Alpine.onBeforeComponentInitialized(component => {
    if (! component.$el.hasAttribute('x-title')) {
        if (component.$data.constructor.prototype instanceof AlpineComponent) {
            component.$el.setAttribute('x-title', component.$data.constructor.name);
        }
    }
});

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@stancl
Comment options

@ryangjchandler
Comment options

@HugoDF
Comment options

@stancl
Comment options

Comment options

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

Answer selected by stancl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants