Skip to content
Discussion options

You must be logged in to vote

I can not tell you if this a bug in AlpineJS or not but I do have a few ways you can work around it. In general I think if you are tempted to use querySelector, it is probably a sign that you are working in the wrong direction.

One solution is to remove the querySelector line and change the getter to this:

  get selectButtonLabel() {
    return this.$el.dataset.label;
  }

Somehow $el will be the button, so everything works out. Codepen here: https://codepen.io/ramonakira/pen/myErrZL?editors=1011

Another solution is to add an x-ref to the button, and change the getter to (assuming x-ref="buttonSelect"):

  get selectButtonLabel() {
    return this.$refs.buttonSelect.dataset.label;
  }

Cod…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mitosch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants